cfstring

How to convert CFStringRef to NSString?

NSString *aNSString; CFStringRef aCFString; aCFString = CFStringCreateWithCString(NULL, [aNSString UTF8String], NSUTF8StringEncoding); aCFString = CFXMLCreateStringByUnescapingEntities(NULL, aCFString, NULL); How can I get a new NSString from aCFString? ...

Get a calculated length of a Core Foundation string given an encoding

Is there a way to get the length in bytes of a CFString given an arbitrary character encoding? It seems possible because the function CFStringGetSmallestEncoding must do some calculations already, but I don't want to use the smallest encoding, I want to find out how big a buffer I might need to allocate if I want the bytes in UTF-8 encod...

How do I print a CFStringRef in a DTrace action?

I have a DTrace probe catching calls to a function, and one of the function's arguments is a CFStringRef. This is private structure that holds a pointer to a unicode string. But the CFStringRef is not itself a char*, so normal DTrace methods like copyinstr() just return ?cp?, which isn't exactly helpful. So how can I print out the strin...

Creating a CFString object with JNA

I'm trying to get the hang of using JNA with Mac OS X. I want to access a Carbon library, for which there is no Cocoa equivalent, so Rococoa can't help me (I think...) I'm stuck when trying to call a Carbon function that requires CFStringRef as a parameter. How can I create a CFStringRef from a Java String? Here's my attempt so far: ...

Create constant NSString from constant CFStringRef

I am attempting to create a Cocoa Framework that is an object-oriented wrapper around a procedural framework written in the Core Foundation. The procedural framework has a number of constants that are all defined as extern CFStringRef constantName. How should I create NSString constants that directly map to the procedural constants so t...

iPhone + NSString error

Hello, I have static NSString as below: static NSString *bowlerName; In the code I am assigning it with some value as below: -(void)setBowlerSpecifications:(int)playerId { Player *objPlayer = [CricketManagementDAL getBowlerSpecification :playerId]; [objPlayer retain]; bowlerSpecialSkill = objPlayer.specialSkill; bowlerT...

What kind of strings does CFStringCreateWithFormat expects as arguments?

The below example should work with Unicode strings but it doesn't. CFStringRef aString = CFSTR("one"); // in real life this is an Unicode string CFStringRef formatString = CFSTR("This is %s example"); // also tried %S but without success CFStringRef resultString = CFStringCreateWithFormat(NULL, NULL, formatString, aString); // Here I...

How to replace old ParamText/StandartAlert with newer CFString replacements?

ParamText() is an really old way of replacing parameters in a string that is based on Pascal strings. Also StandardAlert is not quite Unicode ready. The new message box (not so new) replacement is CFUserNotificationDisplayNotice but this one expects CFString and I found out that if I'm about to switch to using CFString I'm not able to u...

Objects leaking immediately from allocation using either new or [[Object alloc] init];

While running Instruments to find leaks in my code, after I've loaded a file and populate an NSMutableArray with new objects, leaks pop up! I am correctly releasing the objects. Sample code below: //NSMutableArray declared as a retained property in the parent class if(!mutableArray) mutableArray = [[NSMutableArray alloc] initWi...

Returning NSString, Error Message: Variable is not CFString

Hi all, i shortly started Programming Mac OS X Applications with Cocoa, so its a realy New bee question. Sorry about this. At first my code snippet: - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { Purchaser *actPurchaser = [tableViewDataArray objectAtIndex:row]...