我在NSData中获取设备令牌并将其转换为NSString。在打印设备令牌正确从NSData获取设备令牌给予异常
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
deviceToken = [[devToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
deviceToken = [deviceToken stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"Device Token from NSdata is %@",deviceToken);
}
而且我通过这个从其他类
self.Token = [AppDelegate_iPhone sharedAppDelegate].deviceToken;
但它崩溃的这条线
NSLog(@"Device Token from NSdata is %@",deviceToken);
*** -[CFString respondsToSelector:]: message sent to deallocated instance 0x1f9d00
谢谢..这是现在工作,但它为什么会被释放? – iProgrammer
@IphoneDeveloper'stringByReplacingOccurencesOfString:'返回一个自动释放的对象。如果你不希望它被释放(在运行循环结束时),你需要保留这个值。 – Jilouc
非常感谢这个信息.. :) – iProgrammer