Re: Trying to understand -- please help...

2008-05-22 Thread Andy Lee
On May 22, 2008, at 5:13 PM, Johnny Lundy wrote: My point in using that class reference was simply to show how someone could follow the "manual" and still have his code not work. Actually, the "introductory documentation" never actually says that the convenience constructors always return au

Re: Trying to understand -- please help...

2008-05-22 Thread Sherm Pendley
On Thu, May 22, 2008 at 5:13 PM, Johnny Lundy <[EMAIL PROTECTED]> wrote: > My point in using that class reference was simply to show how someone could > follow the "manual" and still have his code not work. And everyone else's point is that someone who goes straight to the class reference is ski

Re: Trying to understand -- please help...

2008-05-22 Thread glenn andreas
On May 22, 2008, at 4:13 PM, Johnny Lundy wrote: My point in using that class reference was simply to show how someone could follow the "manual" and still have his code not work. Actually, the "introductory documentation" never actually says that the convenience constructors always return

Re: Trying to understand -- please help...

2008-05-22 Thread Johnny Lundy
e, there is nothing wrong with the documentation. On May 22, 2008, at 4:45 PM, lists.apple.com wrote: Message: 13 Date: Thu, 22 May 2008 16:15:22 -0400 From: Andy Lee <[EMAIL PROTECTED]> Subject: Re: Trying to understand -- please help... To: Cocoa-dev Message-ID: <[EMAIL PROTECTED

Re: Trying to understand -- please help...

2008-05-22 Thread Joseph Kelly
If you've got complaints or suggestions for Documentation, then go to http://bugreport.apple.com/ and file a bug. Apple seems intent on working with these kinds of suggestions, esp. if they help newcomers transition to the platform. Sincerely, Joe K. ___

Re: Trying to understand -- please help...

2008-05-22 Thread Andy Lee
On May 22, 2008, at 11:43 AM, Greg Titus wrote: On May 21, 2008, at 12:37 PM, Johnny Lundy wrote: This is just one example of that "little tidbit" that is always left out of these references by Apple. It seems to be the <.O. for some reason. The "tidbit" isn't some extraneous bell or whistl

Re: Trying to understand -- please help...

2008-05-22 Thread Andy Lee
On May 22, 2008, at 12:25 PM, glenn andreas wrote: On May 22, 2008, at 10:43 AM, Greg Titus wrote: A lot of people have already mentioned that the memory management semantics for these methods are the same everywhere and are described in the conceptual documentation. I'd like to answer the

Re: Trying to understand -- please help...

2008-05-22 Thread glenn andreas
On May 22, 2008, at 10:43 AM, Greg Titus wrote: On May 21, 2008, at 12:37 PM, Johnny Lundy wrote: This is just one example of that "little tidbit" that is always left out of these references by Apple. It seems to be the <.O. for some reason. The "tidbit" isn't some extraneous bell or whi

Re: Trying to understand -- please help...

2008-05-22 Thread Greg Titus
On May 21, 2008, at 12:37 PM, Johnny Lundy wrote: This is just one example of that "little tidbit" that is always left out of these references by Apple. It seems to be the <.O. for some reason. The "tidbit" isn't some extraneous bell or whistle; it's always something fundamental. They c

RE: Trying to understand -- please help...

2008-05-22 Thread Caleb Strockbine
On May 21, 2008, at 2:39 PM, Johnny Lundy <[EMAIL PROTECTED]> wrote: Here's why the OP was not aware of the behavior of an NSArray class method: Here's the verbatim documentation for +arrayWithObjects: [...deleted...] See? Not a word about autoreleasing anything, or having to retain the retu

Re: Trying to understand -- please help...

2008-05-21 Thread Michael Vannorsdel
Would be like a cookbook including instructions on how to operate an oven and use a knife to cut vegetables in every single recipe. I think most would find that pretty redundant and diluting, especially when the preface covers these topics in detail. On May 21, 2008, at 8:37 PM, Jens Alfk

Re: Trying to understand -- please help...

2008-05-21 Thread Jens Alfke
On 21 May '08, at 11:35 AM, Johnny Lundy wrote: See? Not a word about autoreleasing anything, or having to retain the returned array. Nada. It also didn't spell out that: the return value is a pointer, pointers are 4 or 8 bytes large, the pointer value zero is special and is named "nil", mes

Re: Trying to understand -- please help...

2008-05-21 Thread Jens Alfke
On 21 May '08, at 12:14 PM, Vijay Malhan wrote: If I'm not wrong "self" equivalent of "this" which points to an instance var. And it is initialized in - init (instance)method. And if it fails to initialize, it's nil. So does "self" even exist when + initialize is called. This is a class

Re: Trying to understand -- please help...

2008-05-21 Thread Jens Alfke
On 21 May '08, at 12:37 PM, Johnny Lundy wrote: I submit that any experienced programmer looking up and turning to a page entitled "NSArray Class Reference" would "expect" that a behavior of the class that results in one's created object being deallocated out from under him would be docume

Re: Trying to understand -- please help...

2008-05-21 Thread Andy Lee
On May 21, 2008, at 2:45 PM, Shawn Erickson wrote: Nonsense. Nonsense again. Yet more nonsense. Lets avoid this kind of "tone" in emails on this list... Yes, please. --Andy correct, clarify, explain, etc. and leave it at that. -Shawn ___ Cocoa-

Re: Trying to understand -- please help...

2008-05-21 Thread Sherm Pendley
On Wed, May 21, 2008 at 5:06 PM, Christopher Nebel <[EMAIL PROTECTED]> wrote: > On May 21, 2008, at 10:36 AM, Sherm Pendley wrote: > > [Objects] are simply released when the autorelease pool they are created >>> in is released - which you can treat as occurring at the end of the method >>> in whi

Re: Trying to understand -- please help...

2008-05-21 Thread Ken Thomases
On May 21, 2008, at 1:35 PM, Johnny Lundy wrote: All it would take is a single sentence under the "Class Methods" header, to say that these methods autorelease the returned object (AND that such autoreleasing means that the object will be deallocated if the method in which it was created re

Re: Trying to understand -- please help...

2008-05-21 Thread Sherm Pendley
On Wed, May 21, 2008 at 1:32 PM, Shawn Erickson <[EMAIL PROTECTED]> wrote: > > Folks please don't point someone at things like NSArrayController when > they are just getting started. Using controller layer / bindings can > make a lot of things easier and cleaner code (heck no code) but it > really

Re: Trying to understand -- please help...

2008-05-21 Thread Hamish Allan
On Wed, May 21, 2008 at 7:35 PM, Johnny Lundy <[EMAIL PROTECTED]> wrote: > All it would take is a single sentence under the "Class Methods" header, to > say that these methods autorelease the returned object (AND that such > autoreleasing means that the object will be deallocated if the method in

Re: Trying to understand -- please help...

2008-05-21 Thread Christopher Nebel
On May 21, 2008, at 10:36 AM, Sherm Pendley wrote: [Objects] are simply released when the autorelease pool they are created in is released - which you can treat as occurring at the end of the method in which the init occurs. Nonsense again. The autorelease pool is emptied at the end of each

Re: Trying to understand -- please help...

2008-05-21 Thread Sherm Pendley
On Wed, May 21, 2008 at 3:14 PM, Vijay Malhan <[EMAIL PROTECTED]> wrote: > Thanks for the pointers to the documentation. This is sample snippet from > the documentation. > > @implementation MyClass > > + (void)initialize > > { > >if ( self == [MyClass class] ) { > >/* put initializatio

Re: Trying to understand -- please help...

2008-05-21 Thread Uli Kusterer
Am 21.05.2008 um 18:47 schrieb Peter Hudson: Any initialiser with a "+" in front of it returns an autoreleased object NO! Several mistakes in this sentence: 1) "+" simply means that it is a method of the class, not of individual instances. It has NOTHING to do with whether the result i

Re: Trying to understand -- please help...

2008-05-21 Thread Sherm Pendley
On Wed, May 21, 2008 at 3:37 PM, Johnny Lundy <[EMAIL PROTECTED]> wrote: > > I submit that any experienced programmer looking up and turning to a page > entitled "NSArray Class Reference" would "expect" that a behavior of the > class that results in one's created object being deallocated out from

Re: Trying to understand -- please help...

2008-05-21 Thread Uli Kusterer
Am 21.05.2008 um 18:34 schrieb Gérard Iglesias: In fact in its original case, there would be a crash, because cityArray would point to a trashed pointer... I don't understand why it is not crashing. Well, it's not a trashed pointer. The memory has been alloced (and self is set already),

Re: Trying to understand -- please help...

2008-05-21 Thread Sherm Pendley
On Wed, May 21, 2008 at 2:48 PM, Bill Bumgarner <[EMAIL PROTECTED]> wrote: I have taught/mentored/managed/reviewed/interviewed literally hundreds of > Cocoa programmers over the past two decades (counting Cocoa's NeXT produced > predecessors). My experience has been that the most successful Coco

Re: Trying to understand -- please help...

2008-05-21 Thread Sherm Pendley
On Wed, May 21, 2008 at 2:35 PM, Johnny Lundy <[EMAIL PROTECTED]> wrote: > Here's why the OP was not aware of the behavior of an NSArray class method: > Here's the verbatim documentation for +arrayWithObjects: > > arrayWithObjects: >> Creates and returns an array containing the objects in the arg

Re: Trying to understand -- please help...

2008-05-21 Thread Jeff LaMarche
On May 21, 2008, at 3:37 PM, Johnny Lundy wrote: I submit that any experienced programmer looking up and turning to a page entitled "NSArray Class Reference" would "expect" that a behavior of the class that results in one's created object being deallocated out from under him would be docum

Re: Trying to understand -- please help...

2008-05-21 Thread Andy Lee
On May 21, 2008, at 3:14 PM, Vijay Malhan wrote: Thanks for the pointers to the documentation. This is sample snippet from the documentation. @implementation MyClass + (void)initialize { if ( self == [MyClass class] ) { /* put initialization code here */ } } If I'm not wrong

Trying to understand -- please help...

2008-05-21 Thread Johnny Lundy
On May 21, 2008, at 3:03 PM, [EMAIL PROTECTED] wrote: It is expected that you have at least looked at the getting started documentation before you attempt to dive much into anything else. You would quickly run across the following... Well, that makes the point that some of us are trying to m

Re: Trying to understand -- please help...

2008-05-21 Thread Shawn Erickson
On Wed, May 21, 2008 at 12:14 PM, Vijay Malhan <[EMAIL PROTECTED]> wrote: > Thanks for the pointers to the documentation. This is sample snippet from > the documentation. > > @implementation MyClass > > + (void)initialize > > { > > if ( self == [MyClass class] ) { > > /* put initializat

Re: Trying to understand -- please help...

2008-05-21 Thread Vijay Malhan
Thanks for the pointers to the documentation. This is sample snippet from the documentation. @implementation MyClass + (void)initialize { if ( self == [MyClass class] ) { /* put initialization code here */ } } If I'm not wrong "self" equivalent of "this" which points to an

Re: Trying to understand -- please help...

2008-05-21 Thread Michael Vannorsdel
You troubles are all in this method and how you handle cityArray. First you don't need to alloc and init a new array for cityArray as [NSArray arrayWithObjects: c0, ...c9, nil] gives you a new one already with the objects you specified. Another thing you should watch for is there's an auto

Re: Trying to understand -- please help...

2008-05-21 Thread I. Savant
> Pretty soon, the documentation is going to be 80% repetition and 20% actual > unique-to-the-class content. > I understand the frustration initially experienced by reading, say, the docs > to NSArray and not having every last detail spelled out. At the same time, > most of the details are n

Re: Trying to understand -- please help...

2008-05-21 Thread Ilan Volow
The most common (albeit deprecated) example that immediately comes to my mind is here: http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Protocols/NSKeyValueObserving_Protocol/DeprecationAppendix/AppendixADeprecatedAPI.html#/ /apple_ref/occ/clm/NSObject/ setKeys:triggerChang

+initialize (was Re: Trying to understand -- please help...)

2008-05-21 Thread Jason Stephenson
Vijay Malhan wrote: What exactly do you mean by initializing the *class*? what exactly is initialized with +initialize() method? When exactly this method gets called? If you are at all familiar with Java, this is the same thing as a static initializer. It sets up data required

Re: Trying to understand -- please help...

2008-05-21 Thread Shawn Erickson
On Wed, May 21, 2008 at 11:47 AM, Vijay Malhan <[EMAIL PROTECTED]> wrote: >What exactly do you mean by initializing the *class*? what exactly is > initialized with +initialize() method? >When exactly this method gets called? Look for the subsection titles "Initializing a Class Obj

Re: Trying to understand -- please help...

2008-05-21 Thread I. Savant
>What exactly do you mean by initializing the *class*? what exactly is > initialized with +initialize() method? >When exactly this method gets called? Read the documentation! http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Ref

Re: Trying to understand -- please help...

2008-05-21 Thread Shawn Erickson
On Wed, May 21, 2008 at 11:35 AM, Johnny Lundy <[EMAIL PROTECTED]> wrote: > Here's why the OP was not aware of the behavior of an NSArray class method: > Here's the verbatim documentation for +arrayWithObjects: > > >> arrayWithObjects: >> Creates and returns an array containing the objects in the a

Re: Trying to understand -- please help...

2008-05-21 Thread Bill Bumgarner
On May 21, 2008, at 11:35 AM, Johnny Lundy wrote: Seriously, read that assuming you wanted to try out the NSArray class and tell me how it accomplishes its purpose of documenting what it is intended to document. It doesn't. And this pattern is repeated over and over in just about every one o

Re: Trying to understand -- please help...

2008-05-21 Thread Vijay Malhan
On 21-May-08, at 11:37 PM, I. Savant wrote: Consider +(void)initialize ... also, *none* of them are "initializers" by implication because they're class methods. Sorry, these two sentences seem to be contradictory. Let me clarify: +initialize is used to initialize the *class*. No class meth

Re: Trying to understand -- please help...

2008-05-21 Thread Shawn Erickson
> Nonsense. > Nonsense again. > Yet more nonsense. Lets avoid this kind of "tone" in emails on this list... correct, clarify, explain, etc. and leave it at that. -Shawn ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin re

Trying to understand -- please help...

2008-05-21 Thread Johnny Lundy
would have to be copied to all 250 Class Reference pages, but hey, they copy and paste a lot less important boilerplate than that. On May 21, 2008, at 1:53 PM, Peter Hudson wrote: Message: 2 Date: Wed, 21 May 2008 17:47:38 +0100 From: Peter Hudson <[EMAIL PROTECTED]> Subject: Try

Re: Trying to understand -- please help...

2008-05-21 Thread I. Savant
> Consider +(void)initialize ... also, *none* of them are > "initializers" by implication because they're class methods. Sorry, these two sentences seem to be contradictory. Let me clarify: +initialize is used to initialize the *class*. No class methods are *instance* initializers or have anyth

Re: Trying to understand -- please help...

2008-05-21 Thread I. Savant
> Any initialiser with a "+" in front of it returns an autoreleased object ACK! NO! A *method* with a "+" is a "class method", whether it returns an autoreleased object or nothing at all. Class methods that return autoreleased objects are for convenience, but not all of them do. Consider +(vo

Re: Trying to understand -- please help...

2008-05-21 Thread Shawn Erickson
On Wed, May 21, 2008 at 10:11 AM, Gérard Iglesias <[EMAIL PROTECTED]> wrote: > Or am I missing something ? Yes :) You are misreading what he typed I inlined what he typed with the code... - (id) init { // First, you allocate and initialize the cityArray with an empty NSArray (not very usefu

Re: Trying to understand -- please help...

2008-05-21 Thread Ilan Volow
You also want to add a dealloc method to your class that releases cityArray, something like: - (void)dealloc { [cityArray release]; [super dealloc]; } -- Ilan On May 21, 2008, at 12:05 PM, john darnell wrote: Hello Everyone: I decided that it was time for a play period thi

Re: Trying to understand -- please help...

2008-05-21 Thread Sherm Pendley
On Wed, May 21, 2008 at 12:47 PM, Peter Hudson <[EMAIL PROTECTED]> wrote: > The line of code [NSArray arrayWithObjects: c0, ...c9, nil]; produces > an array all right - but as you have used a class initializer, it will auto > release > when you return from the method where it was created. No,

Re: Trying to understand -- please help...

2008-05-21 Thread Shawn Erickson
> You probably want to use a NSArrayController and bind the combo box to that. > When you hit the buttons you change the array through the controller. Folks please don't point someone at things like NSArrayController when they are just getting started. Using controller layer / bindings can make a

Re: Trying to understand -- please help...

2008-05-21 Thread Hank Heijink (Mailinglists)
On May 21, 2008, at 12:49 PM, Gérard Iglesias wrote: with an empty NSArray (not very useful, since you can't add items to an NSArray). Then, you leak that allocated memory by setting cityArray to an autoreleased NSArray In fact it is not leaking, it is just creating an object for nothing,

Re: Trying to understand -- please help...

2008-05-21 Thread Bill Bumgarner
On May 21, 2008, at 9:49 AM, Gérard Iglesias wrote: with an empty NSArray (not very useful, since you can't add items to an NSArray). Then, you leak that allocated memory by setting cityArray to an autoreleased NSArray In fact it is not leaking, it is just creating an object for nothing, i

Re: Trying to understand -- please help...

2008-05-21 Thread Shawn Erickson
On Wed, May 21, 2008 at 9:47 AM, Peter Hudson <[EMAIL PROTECTED]> wrote: > The line of code [NSArray arrayWithObjects: c0, ...c9, nil]; produces > an array all right - but as you have used a class initializer, it will auto > release when you return from the method where it was created. They are

Re: Trying to understand -- please help...

2008-05-21 Thread Gérard Iglesias
Le 21/05/08 à 19:03, "Clark Cox" <[EMAIL PROTECTED]> a écrit : >On Wed, May 21, 2008 at 9:49 AM, Gérard Iglesias ><[EMAIL PROTECTED]> wrote: >>>with an empty NSArray (not very useful, since you can't add items to >>>an NSArray). Then, you leak that allocated memory by setting cityArray >>>to an aut

Re: Trying to understand -- please help...

2008-05-21 Thread Clark Cox
On Wed, May 21, 2008 at 9:49 AM, Gérard Iglesias <[EMAIL PROTECTED]> wrote: >>with an empty NSArray (not very useful, since you can't add items to >>an NSArray). Then, you leak that allocated memory by setting cityArray >>to an autoreleased NSArray > > In fact it is not leaking, it is just creating

Re: Trying to understand -- please help...

2008-05-21 Thread Gérard Iglesias
>with an empty NSArray (not very useful, since you can't add items to >an NSArray). Then, you leak that allocated memory by setting cityArray >to an autoreleased NSArray In fact it is not leaking, it is just creating an object for nothing, it will be released by the autorelease pool, than no

Trying to understand -- please help...

2008-05-21 Thread Peter Hudson
The line of code [NSArray arrayWithObjects: c0, ...c9, nil]; produces an array all right - but as you have used a class initializer, it will auto release when you return from the method where it was created. Any initialiser with a "+" in front of it returns an autoreleased object - hen

RE: Trying to understand -- please help...

2008-05-21 Thread john darnell
a-dev@lists.apple.com Subject: Re: Trying to understand -- please help... Well Something like this is standard : - (id)init { if (!(self = [super init])) return nil; cityArray = [[NSArray alloc] initWithObjects: @&quo

Re: Trying to understand -- please help...

2008-05-21 Thread Gérard Iglesias
Well Something like this is standard : - (id)init { if (!(self = [super init])) return nil; cityArray = [[NSArray alloc] initWithObjects: @"New York" ..., nil]; return self; } would wor

Re: Trying to understand -- please help...

2008-05-21 Thread João Pavão
Also, since the initializer methods of the superclasses aren't invoked automatically for you, you should code your initializers using a pattern along the lines of: - init { if (self = [super init]) { // ... initialization statements for the instance variables of this

RE: Trying to understand -- please help...

2008-05-21 Thread john darnell
Jake Carter Sent: Wednesday, May 21, 2008 11:16 AM To: cocoa-dev@lists.apple.com Subject: Fwd: Trying to understand -- please help... Sorry, forgot to cc the group on this. :// Jake -- Forwarded message -- From: Jake Carter <[EMAIL PROTECTED]> Date: Wed, May 21, 2008

Re: Trying to understand -- please help...

2008-05-21 Thread Hank Heijink (Mailinglists)
On May 21, 2008, at 12:05 PM, john darnell wrote: - (id) init { cityArray = [[NSArray alloc] init]; NSString *c0 = @"New York"; //Ten NSString objects created here ... NSString *c9 = @"Virginia Beach"; cityArray = [NSArray arrayWithObjects: c0, ...c9, nil]; return self; } Here's

Re: Trying to understand -- please help...

2008-05-21 Thread Paul Bailey
What you're doing here is allocating an empty array, and then setting the pointer of your instance variable to a new array, created with the arrayWithObjects message. An array returned by this message is autoreleased, so at the end of your init method, it's being released. All these type of conve

Re: Trying to understand -- please help...

2008-05-21 Thread Vijay Malhan
You are not retaining the autoreleased array in your constructor. You are over-riding the first initialization of your array(which is a leak) while you are initializing with arrayWithObjects: call. You can remove this line completely cityArray = [[NSArray alloc] init]; and do a retain on this

Fwd: Trying to understand -- please help...

2008-05-21 Thread Jake Carter
Sorry, forgot to cc the group on this. :// Jake -- Forwarded message -- From: Jake Carter <[EMAIL PROTECTED]> Date: Wed, May 21, 2008 at 9:14 AM Subject: Re: Trying to understand -- please help... To: john darnell <[EMAIL PROTECTED]> Ok, I'm somewhat of a beg

Re: Trying to understand -- please help...

2008-05-21 Thread Torsten Curdt
You probably want to use a NSArrayController and bind the combo box to that. When you hit the buttons you change the array through the controller. HTH ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moder

Trying to understand -- please help...

2008-05-21 Thread john darnell
Hello Everyone: I decided that it was time for a play period this morning so I set a task for myself; to place a combo box on a dialog and populate it with the names of ten cities--no more than that. I just wanted to see if my understanding of the language had progressed enough to do so. I built