I have a dictionary instance declared in PageOneView.h:
@interface PageOneView : UIViewController <UITableViewDataSource,
UITableViewDelegate,
UITextFieldDelegate>
{
NSDictionary *orderDetailsDictionary ;
}
@property (nonatomic, retain )NSDictionary *orderDetailsDictionary;
I synthesize it in PageOneView.m:
@implementation PageOneView
@synthesize orderDetailsDictionary;
I initialize it with an object returned by JSONSerialization class. (orderDetailsJSON is a JSON string I have read from a web service) This line is borrowed from the Apple sample code:
orderDetailsDictionary = [NSJSONSerialization JSONObjectWithData:
[orderDetailsJSON dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
Next I try to get the first key.
NSString *valString = [NSString stringWithFormat:
@"%@\n", [[orderDetailsDictionary allKeys] objectAtIndex:0]];
allKeys crashes here with Program received signal: EXC_BAD_ACCESS. the output screen shows:
-[__NSCFArray allKeys]: unrecognized selector sent to instance 0x6a211d0
Obviously,
orderDetailsDictionaryis not aNSDictionary, but aNSArray. You should check the data coming from your server.