core-foundation

Should I verify objects inside Foundation API containers?

In languages like C++ and C# when you create a contain such as a std::vector or a C# list you explicitly declare the container type when you create it: C++: std::vector<MyObject> C#: List<MyObject> list = new List<MyObject>(); Looking at the code above, I know immediately that these containers can only contain objects of type MyOb...

Determining what a CFTypeRef is?

I have a function which returns CFTypeRef. I have no idea what it really is. How do I determine that? For example it might be a CFStringRef. ...

Sendind pointers to different process and using them?

Is it possible to send a pointer to an object via Mach IPC by casting it into an int and then casting it back into the object. Would that work and how can that be done? I want to send a CALayer object over to a different process. I don't think I can send raw objects via Mach IPC. ...

Getting notified when a VPN connection disconnects

How can I, within my Cocoa app, get a notification when the currently running VPN connection disconnects? I'm running Snow Leopard. ...

Should I release this? Memory Management in Objective-C

Should I release strPhone? What about the coreFoundation object being cast to an NSString? What happens to it? strPhone = [[NSString alloc] initWithUTF8String: [[(NSArray *)ABMultiValueCopyArrayOfAllValues(theProperty) objectAtIndex:identifier] UTF8String]]; Thanks for helping me understand. ...

Symbol not found: _OBJC_CLASS_$_NSURL error when launching on Mac OS X Leopard

I've just gotten a report from a user that a new build of my app crashes on his machine when he tries to launch it. The crash report is: Process: MyApp [222] Path: /Applications/MyApp.app/Contents/MacOS/MyApp Identifier: com.MyCompany.MyAppAppAndImporter Version: ??? (???) Code Type: X86-64 (Native...

CFHTTPStream segmentation faul during NSRunLoop

I'm trying to assemble a toy application to interact with http servers via CoreFoundation. I'm not using NSURLConnection because I want to be able to specify a proxy different from the one set in the OSX System Preferences. My problem is that I wasn't able to find any working example and the Apple documentation do not provide a working ...

Universal App won't run on iPad Simulator

I have an existing iPhone app that I'm trying to convert into a universal app for both iPhone and iPad. Everything seems to work fine when I run it on an iPad device, but I get the following runtime error when I try to run in the iPad simulator: dyld: Symbol not found: _CFXMLNodeGetInfoPtr Referenced from: /System/Library/Frameworks/S...

CFMessagePort name conflict

I have created a worker thread that uses a CFRunLoop to receive messages from a CFSocket. Now I need to send other messages to the worker thread so a CFMessagePort looked ideal. However its entirely non obvious to use: The documentation states that the name parameter is needed when communicating between processes. In my worker thread I...

CoreFoundation vs Foundation

In iPhone development, speed is of the essence. Does anyone know if there is a speed difference between using a CoreFoundation type (like CFMutableDictionaryRef) versus a Foundation type (its counterpart, NSMutableDictionary). I would think manipulating the CF type would be faster as it doesnt have to throw around ObjC runtime messages,...

How can I clear the contents of an NSMutableAttributedString?

I have an ivar which is alloc-inited in the init of an object: attString = [[NSMutableAttributedString alloc] init]; On a loop, I want to clear the contents of attString and re-use it. How do I do this? Thanks! ...

Garbage Collector and Core Foundation

Hi, I wrote a method for load Image into CALayer. This is the code: - (CGImageRef)loadImage:(NSString*)path { // Get data image CGImageRef image = NULL; NSData *data = [NSData dataWithContentsOfFile:path]; CFDataRef imgData = (CFDataRef)data; CGDataProviderRef imgDataProvider = CGDataPr...

Sending the intValue message to a NSNumber causes a "Bad Access" error

I'm trying to get the integer value of an NSNumber initialized with a float and I was expecting that intValue handle the conversion (as the docs say). #import <Foundation/Foundation.h> #import "Fraction.h" #import "Complex.h" #import "ComplexMathOps.h" int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutore...

Sending messages to a thread?

I need to imlement in cocoa, a design that relies on multiple threads. I started at the CoreFoundation level - I created a CFMessagePort and attached it to the CFRunLoop, but it was very inconvenient as (unlike on other platforms) it needs to have a (systemwide) unique name, and CFMessagePortSendRequest does not process callbacks back t...