• 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: NSEnumerator -> NSPopupButton (was: Re: NSPipe / NSTask ls -> Array)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSEnumerator -> NSPopupButton (was: Re: NSPipe / NSTask ls -> Array)


  • Subject: Re: NSEnumerator -> NSPopupButton (was: Re: NSPipe / NSTask ls -> Array)
  • From: Prachi Gauriar <email@hidden>
  • Date: Sun, 16 Jul 2006 10:55:31 -0400


On Jul 16, 2006, at 6:35 AM, email@hidden wrote:

NSEnumerator* allObjects = [ttysArray objectEnumerator];
id eachObject;
while(eachObject = [allObjects nextObject]) {
NSLog(@"%@", eachObject); // (this one correctly shows my directorys?????)
[NSPopUpButton addItemWithTitle:eachObject]; // this one crashes the app
}


I added the NSEnumerator thing and after that i want to add the devices
i found via NSFileManager / NSPredicate to an NSPopupButton.

A couple of things. First, you're sending NSPopUpButton the addItemWithTitle: message instead of an instance of NSPopUpButton. You need to be sure you're sending messages to objects, not their classes. What have you used to learn Cocoa so far? The Cocoa Fundamentals Guide


<http://developer.apple.com/documentation/Cocoa/Conceptual/ CocoaFundamentals/index.html>

will probably be really helpful. In the navigation menu on the left side of the screen, be sure to look at The Objective-C Programming Language too.

Also, using an enumerator with an array is actually less efficient (and harder to understand, IMO) than just using a for loop like:

unsigned ttyCount = [ttysArray count];
for (unsigned i = 0; i < ttyCount; i++) {
    [ttyPopUpButton addItemWithTitle:[ttysArray objectAtIndex:i]];
}

-Prachi
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Re: NSEnumerator -> NSPopupButton (was: Re: NSPipe / NSTask ls -> Array)
      • From: "Michael Ash" <email@hidden>
References: 
 >Re: NSPipe / NSTask ls -> Array (From: Prachi Gauriar <email@hidden>)
 >Re: NSPipe / NSTask ls -> Array (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Correct value for spell checking
  • Next by Date: Re: [OT] Unit tests?
  • Previous by thread: Re: NSEnumerator -> NSPopupButton (was: Re: NSPipe / NSTask ls -> Array)
  • Next by thread: Re: Re: NSEnumerator -> NSPopupButton (was: Re: NSPipe / NSTask ls -> Array)
  • Index(es):
    • Date
    • Thread