IPAD must-haves. And fun-to-haves.

Brighten your iPad with a colorful cover, stream to your TV, download pictures from your digital camera, and more. There’s already so much you can do with iPad and iPad mini

Apple Wireless Keyboard

The incredibly thin Apple Wireless Keyboard uses Bluetooth technology, which makes it compatible with iPad

Apple unveils iPad mini: ‘Thin as a pencil, light as paper’

iPad inspires creativity and hands-on learning with features you won’t find in any other educational tool

Lightning connector and FaceTime HD camera

Apple announces 4th generation iPad packing an A6X CPU

Pages

Showing posts with label CFArray. Show all posts
Showing posts with label CFArray. Show all posts

Thursday, February 14, 2013

CFDictionary in a CFArray

Hi all.

 

I'm trying to follow the HIDManager documentation to setup some Joystick/Gampage code to my app.

In my obj-c class I have started two methods (see below).

 

The first is incomplete as I have hit a warning that I don't understand and wish to get rid of this :

 

Passing 'CFArrayRef' (aka 'const struct__CFArray *') to parameter of type 'CFMutableArrayRef' ( 'const struct__CFArray *') discards qualifiers.

 

What's that exactly mean and how would I rectify my code to remove the warning?

 

Cheers

Steve

 

 

- (void) openHardwareConnection

{

   

    HIDManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);

 

    CFArrayRef matchingCFArrayRef = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);

   

    CFDictionaryRef matchingCFDictRef = [self buildDeviceMatchingCFDictionaryRef : kHIDPage_GenericDesktop : kHIDUsage_GD_Joystick];

   

    CFArrayAppendValue(matchingCFArrayRef, matchingCFDictRef);    // WARNING HERE

   

    matchingCFDictRef = [self buildDeviceMatchingCFDictionaryRef : kHIDPage_GenericDesktop : kHIDUsage_GD_GamePad];

   

    CFArrayAppendValue(matchingCFArrayRef, matchingCFDictRef);    // WARNING HERE

       

    CFRelease(matchingCFDictRef);

   

    //...... more hid stuff to follow

   

   

}

 

 

 

- (CFMutableDictionaryRef) buildDeviceMatchingCFDictionaryRef : (UInt32) inUsagePage : (UInt32) inUsage

{

    // Create a dictionary to add usage page/usages to

   

    CFMutableDictionaryRef HIDDeviceMatchingCFDictionaryRef = CFDictionaryCreateMutable( kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks );

   

    CFNumberRef pageCFNumberRef = CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &inUsagePage );

           

    CFDictionarySetValue( HIDDeviceMatchingCFDictionaryRef, CFSTR(kIOHIDDeviceUsagePageKey), pageCFNumberRef );

               

    CFRelease(pageCFNumberRef);

 

    CFNumberRef usageCFNumberRef = CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &inUsage );

                   

    CFDictionarySetValue(HIDDeviceMatchingCFDictionaryRef, CFSTR(kIOHIDDeviceUsageKey), usageCFNumberRef);

                       

    CFRelease(usageCFNumberRef);

                 

    return HIDDeviceMatchingCFDictionaryRef;

}


View the original article here