开发者

No object pairs in plist reading data from a server

I am trying to read a plist from a server. I know for a fact that the plist is valid since when I go to the URL i get the plist downloaded and the plist editor shows me my array properly. Now when I use the following code I get now array populated. I see the data is in there. In debugger i see that plistData has value however the array petListArray has no data at all. What is wrong?

    - (void)getPetListRequestFinished:(ASIHTTPRequest *)request
    {   
        NSData *plistData = [request responseData];
        NSError *error = nil;
        NSPropertyListFormat format = NSPropertyListBinaryFormat_v1_0;
        NSArray *petListArray = (NSArray *)[NSPropertyListSerialization propertyListWithData:plistData 
                                                                         options:(NSPropertyListReadOptions)NSPropertyListImmu开发者_运维知识库table format:&format error:(NSError **)error];


    if(error){

        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"GetPetListError"  message:[NSString stringWithFormat:@"getPettListRequestFinished_new deserialization error: error = %@", error] 
                                                        delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        [alert release];
        return;
    } 
----snip-------


You are passing the wrong type of argument for the error: slot of - NSPropertyListSerialization propertyListWithData:options:format:error:. Try:

[NSPropertyListSerialization propertyListWithData: plistData 
                             options: (NSPropertyListReadOptions) NSPropertyListImmutable
                             format: &format 
                             error: &error]

(edited after checking docs)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜