开发者

not able to take parsed values in string iphone

开发者 https://www.devze.com 2023-03-10 06:01 出处:网络
when I am executig this code .. NSMutableArray *feed2=(NSMutableArray *) [facebook_response objectForKey:@\"paging\"];

when I am executig this code ..

NSMutableArray *feed2  =(NSMutableArray *) [facebook_response objectForKey:@"paging"];

in console I am getting ...

{
next = "https://graph.facebook.com/xyz/posts?limit=15&&until=1305300725";
previous = "https://graph.facebook.com/xyz/posts?limit=15&&since=13070开发者_JS百科32141";
}

Now

I am trying to take it in the array and from that I am trying to take it in the string...

like this

for (i=1; i<[feed2 count]; i++){
    NSString* pagString=[[feed2 objectAtIndex:i]
    NSString* myPaging=[pagString valueForKey:@"next"];

}

however it is creshing at the this point..

can anyone tell me what to do?


You need to clarify several things in your question such as what you're trying to do, and what you're parsing (JSON I'm assuming).

You should also specify what the crash log says (which I'm assuming is an ArrayIndexOutOfBoundsException).

This is so because feed2 is not an array and should not be read as an array (which I can tell looking ar your JSON). It contains no objects so trying to access the first object at index 0 like you're trying to do with objectAtIndex:, will cause a crash.

Create feed2 using:

NSDictionary *feed2 = (NSDictionary *)[facebook_response objectForKey:@"paging"];

In this case it contains key-value pairs so you need only the following to get the string you want:

NSString *myPaging = (NSString *)[feed2 valueForKey:@"next"];
0

精彩评论

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