Re: Integer as key in NSMutableDictionary
Wow, I'm learning a lot from this list. Thanks all for everything, now my code is finally working as I had wanted. :) Weydson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: how to combine addObject in mutablearray with Object instantiation?
Oops, wrong list :) On Tue, May 5, 2009 at 1:05 AM, Weydson Lima wrote: > Sorry for jumping in, but I have a question in the following line: > >> For other objects, you'll have to use a convenience method like: >> >>[myArray addObject:[NSNumber numberWithInt:7]]; >> > > When you add a NSNumber object, how can you quickly reference back to it? > Let's say you want to find the index in the array of the object you just > created. If you use indexOfObject:[NSNumber numberWithInt:7] that wouldn't > work, right? Because a new pointer is being created... > I'm actually working with a NSDictionary which I am having > troubles referencing back to a key. > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: how to combine addObject in mutablearray with Object instantiation?
Sorry for jumping in, but I have a question in the following line: > For other objects, you'll have to use a convenience method like: > >[myArray addObject:[NSNumber numberWithInt:7]]; > When you add a NSNumber object, how can you quickly reference back to it? Let's say you want to find the index in the array of the object you just created. If you use indexOfObject:[NSNumber numberWithInt:7] that wouldn't work, right? Because a new pointer is being created... I'm actually working with a NSDictionary which I am having troubles referencing back to a key. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Integer as key in NSMutableDictionary
Thanks all for the replies. I clearly understand now that I should use NSNumber instead of NSInteger. However, another question came up: when I use the removeObjectForKey, how can I make a reference to a specific key? Let's say I want to remove key that was initialized with [NSNumber numberWithInt:1]. If I call removeObjectForKey:[NSNumber numberWithInt:1], that method won't work because a new NSNumber pointer is being created, correct?The only solution I could find is to use enumeration and go through each key and gets its integer value. Thank you On Mon, May 4, 2009 at 6:24 PM, Jean-Daniel Dupas wrote: > > Le 4 mai 09 à 22:58, Alexander Heinz a écrit : > > On May 4, 2009, at 3:22 AM, Weydson Lima wrote: >> >>> I know that these methods are expecting pointers as parameters and I am >>> passing a scalar. So, what's the best way to approach that? >>> >> >> That's correct. You really shouldn't put any scalar types in an >> NSDictionary (or any other container type in the Cocoa API.) >> > > Not quite true. NSHashTable and NSMapTable are part of Cocoa API and are > design to support NSInteger directly. > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/weyseal%40gmail.com > > This email sent to weys...@gmail.com > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Integer as key in NSMutableDictionary
Hi, Assume that: NSMutableDictionary *result = [[NSMutableDictionary alloc] initWithCapacity:10]; NSInteger ID; And I add objects to the dictionary: [result setObject:[NSArray arrayWithObjects: {... objects ...} nil] forKey:ID]; I am getting warnings when adding integers in the array and assigning the integer ID as a key. The code does work though, but I am guessing there is a better way to accomplish what I want. I know that these methods are expecting pointers as parameters and I am passing a scalar. So, what's the best way to approach that? Thank you ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Loading a view controller from a tab bar controller
Hello there, Another noob question that I couldn't find a solution yet. In my mainwindow xib file, I have a tab bar controller which has two different view controllers. However, when I create those view controllers, how can I set the view property to a view controller instead of just a view? IB doesn't let me to drag the view property of the File Owner to a view controller. Instead, it only lets me to drag it to a UIView. But that doesn't accomplish what I want - which is to load a ViewController. Any ideas? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Two view controllers in one set of files (Noob question)
Thanks for the replies. I looked around the net and found some tutorials on how to create multiple views in a single nib file. I was just confused on how to do that. But you are right, it's better to have unique classes files for each views. Weydson On Mar 25, 2009, at 11:31 AM, Weydson Lima wrote: Hi there, I want to set up two view controllers but I don't want to create a XIB and .m/.h for each controller. Is it possible to use a single set of files to do so? As I was reading the book by Mark and LaMarche, it looks that their approach is to create a pair of those files for each View Controller. Thank you. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Two view controllers in one set of files (Noob question)
Hi there, I want to set up two view controllers but I don't want to create a XIB and .m/.h for each controller. Is it possible to use a single set of files to do so? As I was reading the book by Mark and LaMarche, it looks that their approach is to create a pair of those files for each View Controller. Thank you. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Windows vs View
Hi there, This is my first message here and I am already starting with a very newbie question. I have a broad understanding what a view is - a button, a label, etc... are views, right? But when I look at some sample codes from Apple, the application doesn't have a "main" window.. instead, it has a view and a view controller. So, what's the difference between a window and a view? Can an application have no window but multiple views? Thanks, Weydson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com