cfstring

How to get an array of sentences using CFStringTokenizer?

落爺英雄遲暮 提交于 2020-01-20 02:44:35
问题 I've created an string tokenizer like this: stringTokenizer = CFStringTokenizerCreate( NULL , (CFStringRef)str , CFRangeMake(0, [str length]) , kCFStringTokenizerUnitSentence , userLocale); But how do I obtain those sentences now from the tokenizer? The CF String Programming Guide doesn't mention CFStringTokenizer or tokens (did a full-text search in the PDF). 回答1: Here is an example of CFStringTokenizer usage: CFStringRef string; // Get string from somewhere CFLocaleRef locale =

What is __CFString?

梦想与她 提交于 2019-12-25 01:08:17
问题 I have arg1 which is an IMessage. IMessage is defined as: struct IMessage { ... struct CFString _field2; ... }; and CFString is defined as: struct CFString { void **_vptr$CFObject; struct __CFString *mCFRef; _Bool mIsMutable; }; and __CFString is defined as: struct __CFString; My goal is to get a string of some sort be it NSString or CFStringRef from arg1, so how can i do it? Thanks. Here is the error I get when I try to nslog mCFRef: Thread 0 crashed: # 1 0x97b41edb in _objc_msgSend +

What Is -[NSURL _fastCharacterContents]:?

梦想的初衷 提交于 2019-12-23 17:24:31
问题 So I'm calling this in a method: -(id)initWithContentURL:(NSString *)url { if (self = [super init]) { NSLog(@"xSheetMusicViewController - %@",url); // Casting an NSString object pointer to a CFStringRef: CFStringRef cfString = (CFStringRef)url; CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), cfString, NULL, NULL); pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); } return self; } Which crashes right at the NSLog at the line marked: CFURLRef pdfURL =

How to convert a swift String to CFString

我只是一个虾纸丫 提交于 2019-12-18 12:49:42
问题 How can i create a CFString from a native swift String or NSString in swift let path:String = NSBundle.mainBundle().pathForResource(name.stringByDeletingPathExtension, ofType:"pdf") let string:CFString = ??? path let url:CFURLRef = CFURLCreateWithFileSystemPath(allocator:kCFAllocatorDefault, filePath:string, pathStyle:CFURLPathStyle.CFURLPOSIXPathStyle, isDirectory:false) 回答1: Just cast it: var str = "Hello, playground" as CFString NSString(format: "type id: %d", CFGetTypeID(str)) 回答2: If you

How do I print a CFStringRef in a DTrace action?

五迷三道 提交于 2019-12-12 07:53:33
问题 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 string in the DTrace action? 回答1: As far as I know, there is not built-in support for this kind of thing. Usually a library would publish a probe that decodes

NSData encoding

梦想与她 提交于 2019-12-12 06:10:02
问题 Currently, I'm trying to parse an NSData in my iOS app. Problem is, I can't seem to find a proper hebrew encoding for parsing. I must decode the data using the Windows-1255 encoding (hebrew encoding type for windows) or ISO 8859-8 encoding, or I'll get plain gibberish. The closest I've got to solving the issue was using CFStringConvertEncodingToNSStringEncoding(CFStringEncodings.ISOLatinHebrew) yet it throws 'CFStringEncodings' is not convertible to 'CFStringEncoding' (notice Encoding s vs

How to create a CFDictionary in an OS X target?

▼魔方 西西 提交于 2019-12-10 09:26:29
问题 According to documentation CFDictionaryCreate is used to instantiate CFDictionary in swift . func CFDictionaryCreate(_ allocator: CFAllocator!, _ keys: UnsafeMutablePointer<UnsafePointer<Void>>, _ values: UnsafeMutablePointer<UnsafePointer<Void>>, _ numValues: CFIndex, _ keyCallBacks: UnsafePointer<CFDictionaryKeyCallBacks>, _ valueCallBacks: UnsafePointer<CFDictionaryValueCallBacks>) -> CFDictionary! How can I create the keys and values arguments? So far I've tried to use swift's String type

How to create a CFDictionary in an OS X target?

风格不统一 提交于 2019-12-05 13:45:20
According to documentation CFDictionaryCreate is used to instantiate CFDictionary in swift . func CFDictionaryCreate(_ allocator: CFAllocator!, _ keys: UnsafeMutablePointer<UnsafePointer<Void>>, _ values: UnsafeMutablePointer<UnsafePointer<Void>>, _ numValues: CFIndex, _ keyCallBacks: UnsafePointer<CFDictionaryKeyCallBacks>, _ valueCallBacks: UnsafePointer<CFDictionaryValueCallBacks>) -> CFDictionary! How can I create the keys and values arguments? So far I've tried to use swift's String type hoping it would be automatically converted to appropriate types: import Foundation var keys : [String]

[CFString release]: message sent to deallocated instance

元气小坏坏 提交于 2019-12-01 04:05:39
I've been struggling with a strange problem for two days now. I went through every related question on SO but none solved the issue. I'm working on Xcode5. I'm using ARC and CoreData. On iOS7 (simulator): `[CFString release]: message sent to deallocated instance` Thread 1, Queue : com.apple.main-thread 0 0x03c7d3ba in __kill () 1 0x03c7c4b8 in kill$UNIX2003 () 2 0x0347a921 in ___forwarding___ () 3 0x0347a4ee in _CF_forwarding_prep_0 () 4 0x02b7b002 in -[NSConcreteAttributedString dealloc] () 5 0x02f66692 in objc_object::sidetable_release(bool) () 6 0x02f65e81 in objc_release () 7 0x02f66ce7 in

[CFString release]: message sent to deallocated instance

天大地大妈咪最大 提交于 2019-12-01 00:53:35
问题 I've been struggling with a strange problem for two days now. I went through every related question on SO but none solved the issue. I'm working on Xcode5. I'm using ARC and CoreData. On iOS7 (simulator): `[CFString release]: message sent to deallocated instance` Thread 1, Queue : com.apple.main-thread 0 0x03c7d3ba in __kill () 1 0x03c7c4b8 in kill$UNIX2003 () 2 0x0347a921 in ___forwarding___ () 3 0x0347a4ee in _CF_forwarding_prep_0 () 4 0x02b7b002 in -[NSConcreteAttributedString dealloc] ()