Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我调用了一个 URL,并在失败或成功时收到 0 或 1。我的数据在 NSMutableData *data; 目的。
我得到了数据,但现在想看看它是 1 还是 0。我该怎么做?我需要获取字节吗?
谢谢
您需要将其转换NSData为NSString第一个。然后可以使用intValueon 方法NSString将其转换为整数。
NSData
NSString
intValue
例如:
NSString* response = [[[NSString alloc] initWithData: data encoding: NSASCIIStringEncoding] autorelease]; int value = [response intValue];