• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Getting the right objects in an Array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting the right objects in an Array


  • Subject: Getting the right objects in an Array
  • From: Marcel Borsten <email@hidden>
  • Date: Mon, 5 Nov 2007 18:59:39 +0100

Hello everybody,

I hope someone can help me with the following; I'm trying to use a plist to fill a NSPopupbutton menu item with strings from the plist. The plist looks as follows:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd ">
<plist version='1.0'>
<dict>
<key>List</key>
<array>
<dict>
<key>name</key>
<string>Joe</string>
<key>uuid</key>
<string>A4640553-1C93-4FCD-98FE-917AF1700C6B</string>
</dict>
<dict>
<key>name</key>
<string>Jane</string>
<key>uuid</key>
<string>B6DBECAC-3472-4692- B0FC-6143A46A7B53</string>
</dict>
</array>
</dict>
</plist>



I'm using the following code to fill a NSMutableArray with strings from the NSDictionary object. The for loop gets the instances of the keys 'name' and puts the string in the mutable array object 'firstNames'. In my program it uses the firstNames-array to fill a NSPopupButton with the Array of NSStrings. When that happens the program exits with a “EXC_BAD_ACCESS”-error. It looks to me that the objects in the returned mutable array are not NSString objects. When I debug, Xcode shows my NSString-value as 'invalid'.
.....


	NSArray *myArray = [dict objectForKey: @"List"];
	firstNames = [NSMutableArray array];

	int i, myNameList = [myArray count];

	for ( i = 0; i < myNameList; i++ )	{

NSDictionary *nameEntry = [myArray objectAtIndex: i];

NSString *myName;
myName = [[NSString alloc] initWithString: [nameEntry valueForKey: @"name"]];


		[firstNames addObject: myName];

	}

	return firstNames;
.....

Can anybody give me some clues on what I'm doing horribly wrong here? Thanks,

Marcel

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Getting the right objects in an Array
      • From: Paul Goracke <email@hidden>
    • Re: Getting the right objects in an Array
      • From: "Shawn Erickson" <email@hidden>
  • Prev by Date: Re: NSInvocation problem - "NSView not correctly initialized"
  • Next by Date: Re: Unable to add classes to IB 3.0
  • Previous by thread: Re: Using .Mac iDisk for subversion (svn) repository?
  • Next by thread: Re: Getting the right objects in an Array
  • Index(es):
    • Date
    • Thread