• 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
Re: RETRIEVING AN ARRAY ENTRY FROM AN ARRAY
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RETRIEVING AN ARRAY ENTRY FROM AN ARRAY


  • Subject: Re: RETRIEVING AN ARRAY ENTRY FROM AN ARRAY
  • From: Yann Bizeul <email@hidden>
  • Date: Thu, 5 Feb 2004 17:37:46 +0100

Please avoid re-post and uppercase titles.

You have to use a NSEnumerator to scan your array. For example, and As I remeber without testing :

-------------------
NSArray *deviceArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"DeviceList"];
NSEnumerator *e = [ deviceArray objectEnumerator ];
NSString *currentDevice;

[objectPopUp removeAllItems];
while (currentDevice = [ e nextObject ]) {
[objectPopUp addItemWithTitle:currentDevice];
}
-------------------

Le 4 fivr. 04, ` 13:36, email@hidden a icrit :

Had an error, corrected and resubmitted.

From test plist file
_______________________________________________

<key>DeviceList</key>
<array>
<string>XSKey1</string>
<string>XSKey2</string>
<string>XSKey3</string>
</array>
_______________________________________________

Code
_______________________________________________

[objectPopUp removeAllItems];
NSArray *deviceArray;
deviceArray = [[NSUserDefaults standardUserDefaults]objectForKey:
@"DeviceList"];
[objectPopUp addItemsWithTitles:deviceArray];
_______________________________________________

While this code does work with the array "DeviceList" if it has strings
stored in it as listed.

The problem is that each entry in this array is an array with 3 entries and I
only wish to retrieve the first (0) entry from each array.

Here is the actual plist file content
_______________________________________________

From plist file (corrected due to error in pasting)
_______________________________________________

<key>DeviceList</key>
<array>
<array>
<string>XSKey1</string>
<string>XSKey1.dat</string>
<string>gvggz55l-a4l94772-uoc9sbg</string>
</array>
<array>
<string>XSKey2</string>
<string>XSKey2.dat</string>
<string>gvffz66l-a4l84662-uoc8sbg</string>
</array>
<array>
<string>XSKey3</string>
<string>XSKey3.dat</string>
<string>hkjjm44l-c2319491-ukg6van</string>
</array>
</array>
_______________________________________________


I've tried "arrayForKey" but it doesn't populate the menu and
"stringArrayForKey" doesn't seem to work either so I'm assuming that I should be doing
something else but not sure what, any ideas for a solution???

Dale
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


--
Yann Bizeul - yann at tynsoe.org
http://projects.tynsoe.org/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: RETRIEVING AN ARRAY ENTRY FROM AN ARRAY
      • From: David Blanton <email@hidden>
References: 
 >RETRIEVING AN ARRAY ENTRY FROM AN ARRAY (From: email@hidden)

  • Prev by Date: Re: Prevent ComboBox from dragging
  • Next by Date: Re: ObJC vs. Java -- NEWBIE
  • Previous by thread: RETRIEVING AN ARRAY ENTRY FROM AN ARRAY
  • Next by thread: Re: RETRIEVING AN ARRAY ENTRY FROM AN ARRAY
  • Index(es):
    • Date
    • Thread