开发者

How do I copy an object value from a mutable array into a string?

How do I copy an object value from a mutable array into a string?

The array holds objects from parsed XML, but now I cannot copy the array value into a string.

How can I do th开发者_开发知识库is?


NSNumber has a stringValue message, which returns the object as an NSString:

NSString *foo = [myNSNumber stringValue];

Alternately, if you have a primitive value like NSUInteger, or a float, you can use NSString directly:

NSUInteger nsuint = 20;
CGFloat fff = 21.0;

NSString *foo = [NSString stringWithFormat:@"%ld",(long)nsuint];

//or

NSString *foo = [NSString stringWithFormat:@"%f",fff];

Ole's question stands, however. One way to find out might be to iterate through the array asking for descriptions:

int count = 0;
for (id item in myMutableArray) {
    count +=1;
    NSLog(@"Item %d is a %@", count, [item description]");
}

This doesn't always yield intelligent results, but often does.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜