我有一个NSString
,对于我的生活,我无法弄清楚如何去做remove spaces
,然后接受last 30 characters
它。
像这样的错误:
3/5/13 3:38:30 PM *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType UTF8String]: unrecognized selector sent to instance 0x160bf20'
或者
3/5/13 3:30:51 PM *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType length]: unrecognized selector sent to instance 0x160bf20'
我不明白这些错误。
代码:
NSString* m = (NSString*)CFDictionaryGetValue(diskDesc, kDADiskDescriptionVolumeUUIDKey);
[m stringByReplacingOccurrencesOfString:@" " withString:@""]
NSString *newString = [m substringToIndex:[m length]-30];
另一个更新:
NSString * m = (NSString*)CFDictionaryGetValue(diskDesc, kDADiskDescriptionDeviceModelKey);
NSString * v = (NSString*)CFDictionaryGetValue(diskDesc, kDADiskDescriptionVolumeUUIDKey);
if(m)
{
m = [m stringByReplacingOccurrencesOfString:@" " withString:@""];
}
if(v)
{
if([v length] > 30)
{
NSString *newString = [v substringToIndex:[v length]-30];
}
}