core-foundation

NSUrlRequest: where an app can find the default headers for HTTP request?

只愿长相守 提交于 2019-11-27 15:36:23
问题 Does anybody know where an iOS app can see the default headers that NSUrlRequest sets for an HTTP request? Just creating NSUrlRequest with "http://.." NSURL and then asking: [request allHTTPHeaderFields] returns an empty dictionary. But I know that for example "Accept-Encoding" is set to "gzip" . So I want to get all that fields and show them in a HTTP request demo. I've also tried to swizzle [NSMutableURLRequest setValue:forHTTPHeaderField:] , but it seems that it is not used by underlying

How do I get the currently connected network interface name using Cocoa or Foundation?

隐身守侯 提交于 2019-11-27 13:50:22
I need to know the network interface name of the currently connected network interface, as in en0 , lo0 and so on. Is there a Cocoa/Foundation function that is going to give me this information? You can cycle through network interfaces and get their names, IP addresses, etc. #include <ifaddrs.h> // you may need to include other headers struct ifaddrs* interfaces = NULL; struct ifaddrs* temp_addr = NULL; // retrieve the current interfaces - returns 0 on success NSInteger success = getifaddrs(&interfaces); if (success == 0) { // Loop through linked list of interfaces temp_addr = interfaces;

ios User Prompt when making outgoing call via URL Scheme 10.2+

送分小仙女□ 提交于 2019-11-27 08:24:32
问题 It appears that Apple have changed the behaviour when making a phone call via the URL Scheme. We currently use this code to initiate a phone call: let url = NSURL(string: "tel://011111111111") UIApplication.sharedApplication().openURL() Prior to iOS 10.2, this immediately launched the dialler and placed the phone call. It appears that this has now changed, and the user receives a prompt to confirm to make the phone call. It appears tel:// is behaving more like telprompt://. This is despite

Using IOHIDManager to Get Modifier Key Events

扶醉桌前 提交于 2019-11-27 08:08:50
I'm trying to use IOHIDManager to get modifier key events because Cocoa flagsChanged events are lacking (difficult to differentiate between press/release, left/right if both are down, etc.) Here's the code where I create the manager and register the callback. IOHIDManagerRef hidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); if (CFGetTypeID(hidManager) != IOHIDManagerGetTypeID()) return 1; CFMutableDictionaryRef capsLock = myCreateDeviceMatchingDictionary(0x07, 0x39); CFMutableDictionaryRef lctrl = myCreateDeviceMatchingDictionary(0x07, 0xE0); CFMutableDictionaryRef

Xcode 7 Beta 6, dyld ___NSArray0__ crash

假如想象 提交于 2019-11-27 05:50:11
问题 For the first time I was able to compile my app in Xcode 7 (failed in beta 4 and 5). So, thats good progress I guess. However, when i load my app on my iPhone 6, iOS 8.4.1, it crashed in the debugger with the following message: dyld: Symbol not found: _NSArray0 Referenced from: /private/var/mobile/Containers/Bundle/Application/0294DF62-AE80-485D-BB11-8C3A5D39777D/Boxtiq.app/Boxtiq Expected in: /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /private/var/mobile/Containers

What is an NSCFDictionary?

这一生的挚爱 提交于 2019-11-27 05:27:11
I'm getting an NSCFDictionary returned to me and I can't figure out how to use it. I know it's of type NSCFDictionary because I printed the class and it came out as __NCSFDictionary. I can't figure out how to do anything with it. I'm just trying to hold onto it for now but can't even get that to work: NSDictionary *dict = [[NSURLCredentialStorage sharedCredentialStorage] allCredentials]; for(NSURLProtectionSpace key in [dict keyEnumerator]) { NSCFDictionary *value = [dict objectForKey:key]; } The class reference for allCredentials says its supposed to return a dictionary whose values are also

assign properties, ARC and Core Foundation objects

Deadly 提交于 2019-11-26 22:59:35
问题 Edit 2. Thanks to Ken this is now working. And I even think I understand why :-) Here's the amended line: - (void) reCreatePath { CGMutablePathRef p = ::CGPathCreateMutable() ; ::CGPathMoveToPoint (p, 0, TL.x, TL.y) ; // [snip] ::CGPathAddLineToPoint (p, 0, BL.x, BL.y) ; ::CGPathCloseSubpath(p) ; self.path = p ; ::CGPathRelease(p) ; // <<== THIS IS IT!! :-) } Edit. I still don't get it. I tried Chuck suggestion: @property (nonatomic, strong) __attribute__((NSObject)) CGPathRef path ; Like so:

Using IOHIDManager to Get Modifier Key Events

元气小坏坏 提交于 2019-11-26 17:45:19
问题 I'm trying to use IOHIDManager to get modifier key events because Cocoa flagsChanged events are lacking (difficult to differentiate between press/release, left/right if both are down, etc.) Here's the code where I create the manager and register the callback. IOHIDManagerRef hidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); if (CFGetTypeID(hidManager) != IOHIDManagerGetTypeID()) return 1; CFMutableDictionaryRef capsLock = myCreateDeviceMatchingDictionary(0x07, 0x39)

What is an NSCFDictionary?

偶尔善良 提交于 2019-11-26 12:47:52
问题 I\'m getting an NSCFDictionary returned to me and I can\'t figure out how to use it. I know it\'s of type NSCFDictionary because I printed the class and it came out as __NCSFDictionary. I can\'t figure out how to do anything with it. I\'m just trying to hold onto it for now but can\'t even get that to work: NSDictionary *dict = [[NSURLCredentialStorage sharedCredentialStorage] allCredentials]; for(NSURLProtectionSpace key in [dict keyEnumerator]) { NSCFDictionary *value = [dict objectForKey

iOS start Background Thread

假如想象 提交于 2019-11-26 08:54:47
问题 I have a small sqlitedb in my iOS device. When a user presses a button, I fetch the data from sqlite & show it to user. This fetching part I want to do it in a background thread (to not block the UI main thread). I do this like so - [self performSelectorInBackground:@selector(getResultSetFromDB:) withObject:docids]; After the fetching & a little bit of processing, I need to update the UI. But since (as a good practice) we should not perform UI updation from background threads. I call a