我試圖將常量char *轉換爲NSString *,然後將其轉換回來。它的工作原理,但我得到:將const char *轉換爲NSString *並轉換回來_NSAutoreleaseNoPool()
__NSAutoreleaseNoPool(): Object 0x100550a40 of class NSCFArray autoreleased with no pool in place - just leaking
__NSAutoreleaseNoPool(): Object 0x100551730 of class NSCFString autoreleased with no pool in place - just leaking
__NSAutoreleaseNoPool(): Object 0x100551f10 of class NSCFData autoreleased with no pool in place - just leaking
的代碼是:
const char* convert = "hello remove this: *";
NSString *input = [[NSString alloc] initWithUTF8String:convert];// convert
//remove * FROM THE STRING
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"*"];
// REPLACE * WITH NOTHING
input = [[input componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @""];
// CONVERT BACK
const char *converted_back = [input UTF8String];
我迷路了,請幫我出。
顯示你所有的代碼,我想我知道問題是什麼,但我需要先檢查你的整個代碼。 – 2012-04-23 16:07:20