這是奇怪的。試圖從NSString中刪除小數點
爲iPhone開發我有一個NSString:
distanceFromTargetString = @"6178266.000000"
// this is not actually code, but a value taken from elsewhere. It is a proper NSString though.
當我使用這個
NSArray *listItems = [distanceFromTargetString componentsSeparatedByString:@"."];
distanceFromTargetString = [listItems objectAtIndex:0];
或本
[distanceFromTarget setText: distanceFromTargetString];
我得到這樣的
-[NSDecimalNumber isEqualToString:]: unrecognized selector sent to instance 0x1cac40
2011-07-21 14:29:24.226 AssassinBeta[7230:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSDecimalNumber isEqualToString:]: unrecognized selector sent to instance 0x1cac40'
任何想法?
做你嘗試'[distanceFromTargetString integerValue]'? – 2011-07-21 13:38:41
謝謝文斯。這是做什麼的? –
我認爲你在正確的軌道上,但這種方法不起作用。嘗試發佈它作爲答案雖然:) –