1

I'm new to Xcode. what i want is read plist data locally in my program. i got NSArrayM insertObject:atIndex:]: object cannot be nil error. Here is what i declared and my plist file. Thanks

NSMutableArray *phoneArray;

NSString *path=[[NSBundle mainBundle] pathForResource:@"PhoneList" ofType:@"plist"];

phoneArray= [[NSMutableArray alloc]initWithContentsOfFile:path];

key type Item 0 Dictionary Item 1 Dictionary

Items have description, name keys as type of String.

1
  • 1
    one of youritems in plist is nil... Commented Apr 15, 2012 at 12:16

2 Answers 2

2

Verify your plist, there is most likely a bad value. Items in an NSArray or NSDictionary can not be null. You can use Xcode to open the plist file to verify it.

Personally I use "PlistEdit Pro", it can provide somewhat better diagnostics when the plist is invalid. There is a Free Trial here of PlistEdit Pro.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Zaph. Program helps a lot.
Actually i implemented wrongly plist. Outer tag is the <array> and inner tags are <dic>. Thank you again.
0
- (void)insertObject:(id)anObject atIndex:(NSUInteger)index

The object to add to the array's content. This value must not be nil.

before any input from the plist file, please check to see that the element is not nil, to avoid the excetion

1 Comment

Thanks WhiteTiger i did with NSLog(@"%@",[dic objectForKey:@"Item 0"]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.