Re: NSEnumerator -> NSPopupButton (was: Re: NSPipe / NSTask ls -> Array)
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