简体   繁体   中英

Checking NSString's length

I think I am getting an error when I check my string length. It's only a recent thing since I updated my Xcode for the new iOS 6.

This is how I am checking my NSStrings length

if ([manuIdString length] != 0) {

Then when the thread hits this.. there is defiantly a value in manuIdString but I get this error.

2012-10-11 10:01:57.715 paranioa[8619:907] -[__NSCFNumber length]: unrecognized selector sent to instance 0x1f83ed60
2012-10-11 10:01:57.717 paranioa[8619:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0x1f83ed60'
*** First throw call stack:
(0x36b5b2a3 0x34e6b97f 0x36b5ee07 0x36b5d531 0x36ab4f68 0x25949 0x37f170ad 0x37f17135 0x37f170ad 0x37f1705f 0x37f1703d 0x37f168f3 0x37f16de9 0x37e3f5f9 0x37e2c809 0x37e2c123 0x36fdf5a3 0x36fdf1d3 0x36b30173 0x36b30117 0x36b2ef99 0x36aa1ebd 0x36aa1d49 0x36fde2eb 0x37e80301 0x1fb41 0x3b58cb20)
libc++abi.dylib: terminate called throwing an exception

any help would be greatly appreciated

manuIdString is not an NSString. You have accidentally assigned an NSNumber to it.

Yes I also faced this type of problem fetching values from json and assigning in NSString

Definitly manuIdString is not NSString.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM