Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 01-31-2009, 01:31 AM   #1 (permalink)
krustaeon
Noobieee
 
Join Date: Jan 2009
Location: silicon valley, ca
Posts: 16
krustaeon is on a distinguished road
Default How to add a null array to an NSDictionary

I have a plist file that has an array of dictionaries. Each dictionary item has a string item and an array of strings.

- Array
- Dictionary1
- key1: String
- key2: Array
-String1
-String2
- Dictionary2
- key1: String
- key2: Array
-String1

I tried to add a new dictionary item by executing the following line of code:

NSMutableArray *array2 = nil;
id Dictionary3 = [NSDictionary dictionaryWithObjectsAndKeys: key1, @"key1_string", array2, @"key2"];
[Array insertObjectictionary3 atIndex:[Array count]];

Is this ok or am I completely off the track here?
Should I use NSMutableDictionary instead?
Should I do NSMutableArray *array2 = [NSNull null]; ? but this resulted in Warning when compiled

Then when I try to add a new item to array2, I have the following codes:

NSString *newStr = @"New String Item";
NSMutableDictionary *dict3 = [Array objectAtIndex:[Array count]];
NSMutableArray *key2Array = [dict3 valueForKey:@"key2"];
NSInteger count = [key2Array count];
[array insertObject:newStr atIndex:count];

This failed to add the newStr object to Array-Dict3.

If I added the newStr to Array-Dictionary1 or 2, this worked just fine.

What am I missing here? I'd appreciate any help. Thanks.
krustaeon is offline   Reply With Quote
 

» Advertisements
» Online Users: 448
14 members and 434 guests
brainspoon, ChrisYates, CMSLdesign, dre, elhanche, Gaz, gogoman, iOS.Lover, ketaskin, LegionMD, MysticLine, Robiwan, Sami Gh, thestojkovic
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,614
Threads: 94,086
Posts: 402,792
Top Poster: BrianSlick (7,990)
Welcome to our newest member, kurtroom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:38 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.