标签: cfstring

如何将CFStringRef转换为NSString?

NSString *aNSString;
CFStringRef aCFString;
aCFString = CFStringCreateWithCString(NULL, [aNSString UTF8String], NSUTF8StringEncoding);
aCFString = CFXMLCreateStringByUnescapingEntities(NULL, aCFString, NULL);
Run Code Online (Sandbox Code Playgroud)

我怎样才能得到一个新NSStringaCFString

string cocoa cfstring

165
推荐指数
3
解决办法
9万
查看次数

如何将swift String转换为CFString

如何在swift中从本机swift String或NSString创建CFString

    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)
Run Code Online (Sandbox Code Playgroud)

cfstring swift

33
推荐指数
4
解决办法
2万
查看次数

如何在DTrace操作中打印CFStringRef?

我有一个DTrace探针捕获函数的调用,函数的一个参数是a CFStringRef.这是一个私有结构,它包含一个指向unicode字符串的指针.但CFStringRef它本身并不是一个char*普通的DTrace方法,就像copyinstr()返回一样?cp?,这并不是很有用.

那么如何在DTrace动作中打印出字符串呢?

dtrace cfstring

8
推荐指数
1
解决办法
6784
查看次数

如何使用CFStringTokenizer获取一系列句子?

我已经创建了一个这样的字符串标记器:

stringTokenizer = CFStringTokenizerCreate(
                         NULL
                         , (CFStringRef)str
                         , CFRangeMake(0, [str length])
                         , kCFStringTokenizerUnitSentence
                         , userLocale);
Run Code Online (Sandbox Code Playgroud)

但是如何从tokenizer中获取这些句子呢?CF字符串编程指南未提及CFStringTokenizer或令牌(在PDF中进行了全文搜索).

cocoa nsstring cfstring

8
推荐指数
1
解决办法
2539
查看次数

[CFString release]:发送到解除分配实例的消息

我两天来一直在努力解决一个奇怪的问题.我在SO上经历了所有相关问题但没有一个解决了这个问题.我正在研究Xcode5.我正在使用ARC和CoreData.

在iOS7(模拟器)上:

`[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 (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
8   0x00739bc4 in CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) ()
9   0x0345253e in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
10  0x0345248f in __CFRunLoopDoObservers ()
11  0x034303b4 in __CFRunLoopRun ()
12 …
Run Code Online (Sandbox Code Playgroud)

core-data cfstring nszombie ios

8
推荐指数
1
解决办法
5134
查看次数

如何将NSString路径转换为CFURLRef(对于iOS 3.1)?

我在UIScrollView中显示PDF.为此,我使用:

myDocumentRef = CGPDFDocumentCreateWithURL((CFURLRef)[[NSBundle mainBundle] URLForResource:@"salonMap" withExtension:@"pdf"]);
Run Code Online (Sandbox Code Playgroud)

现在,我尝试使其适用于IOS 3.1(NSBundle URLForResource:3.1中不存在withExtension)

我将代码转换为:

NSString *fullPath =  [[NSBundle mainBundle] pathForResource:@"salonMap" ofType:@"pdf"];
NSLog(@"%@", fullPath);
CFStringRef fullPathEscaped = CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)fullPath, NULL, NULL,kCFStringEncodingUTF8);
CFURLRef urlRef = CFURLCreateWithString(NULL, fullPathEscaped, NULL);
myDocumentRef = CGPDFDocumentCreateWithURL(urlRef);
Run Code Online (Sandbox Code Playgroud)

但它导致了一个

<Error>: CFURLCreateDataAndPropertiesFromResource: failed with error code -15
Run Code Online (Sandbox Code Playgroud)

我确切地说NSLog记录了

/var/mobile/Applications/1CF69390-85C7-45DA-8981-A279464E3249/myapp.app/salonMap.pdf"
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

iphone nsurl cfstring nsbundle ios

7
推荐指数
1
解决办法
6474
查看次数

从CFURLRef或CFStringRef转换为std :: string

如何将a转换CFURLRef为C++ std::string

我还可以从转换CFURLRefCFStringRef方式:

CFStringRef CFURLGetString ( CFURLRef anURL );
Run Code Online (Sandbox Code Playgroud)

但现在我有同样的问题.我怎样才能转换CFStringRefstd::string

c++ macos stdstring cfstring cfurl-encoding

7
推荐指数
2
解决办法
7203
查看次数

将CFStringRef转换为C字符串?

你好可爱的电脑人:

我想将以下CFStringRef转换为CString.知道怎么样?

recordFilePath = (CFStringRef)[NSTemporaryDirectory() stringByAppendingPathComponent: @"recordedFile.wav"];
Run Code Online (Sandbox Code Playgroud)

谢谢!


编辑1

DarkDust答案似乎已接近尾声,但我仍然收到错误(见评论).有帮助吗?

c objective-c cfstring

5
推荐指数
2
解决办法
5590
查看次数

无法将类型为"[CFString]"的值分配给类型为"[String]"的值

我刚下载了新的Xcode 7 beta 5,我找不到解决此错误的方法.它一直突出显示"pickker.mediaTypes = [kUTTypeImage]"这一行,并说"不能将类型'[CFString]'的值赋给'[String]''类型的值"

if (UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)){
        let picker = UIImagePickerController()
        picker.delegate = self
        picker.sourceType = UIImagePickerControllerSourceType.Camera
        picker.mediaTypes = [kUTTypeImage]
        picker.allowsEditing = true
        self.presentViewController(picker, animated: true, completion: nil)
    }
    else{
        NSLog("No Camera.")
    }
Run Code Online (Sandbox Code Playgroud)

cfstring xcode7 xcode7-beta5

5
推荐指数
1
解决办法
690
查看次数

我想在CFSTR中传递一个变量?

在下面的编码中,我想通过CFSTR传递变量,我该怎么办?

ABMutableMultiValueRef address = ABMultiValueCreateMutable(kABDictionaryPropertyType);
// Set up keys and values for the dictionary.

CFStringRef keys[5];

CFStringRef values[5];

keys[0] = kABPersonAddressStreetKey;

keys[1] = kABPersonAddressCityKey;

keys[2] = kABPersonAddressStateKey;

keys[3] = kABPersonAddressZIPKey;

keys[4] = kABPersonAddressCountryKey;

values[0] = CFSTR("Wiztech, 208/B Clifton Center, Karachi");

//values[0] = CFSTR(address1); I want to pass address1 which is NSString, how can I?

values[1] = CFSTR("");

values[2] = CFSTR("");

values[3] = CFSTR("");

values[4] = CFSTR("");
Run Code Online (Sandbox Code Playgroud)

iphone cfstring

4
推荐指数
1
解决办法
4687
查看次数