Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Objective-c > Re: I must be m...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 16 of 40 Topic 980 of 1041
Post > Topic >>

Re: I must be missing something... (Categories)

by Gregory Weston <uce@[EMAIL PROTECTED] > May 14, 2008 at 07:28 AM

In article <wcyeo-DA9303.21382413052008@[EMAIL PROTECTED]
>,
 William Yeo <wcyeo@[EMAIL PROTECTED]
> wrote:

> In article <6YSdnUl709LQoLfVnZ2dnUVZ_ofinZ2d@[EMAIL PROTECTED]
>,
>  Don Bruder <dakidd@[EMAIL PROTECTED]
> wrote:
> 
> > I'm green as grass when it comes to Obj-C, and the whole alloc/init 
> > thing is still rather "fuzzy" to me. *IF* I've understood my reading 
> > correctly, I *THINK* the "[[super alloc] init]" construct grabs space 
> > (via [super alloc] to hold an NSObject, then (still using the NSObject

> > class - I think...) initializes it to "be" an NSObject using the 
> > NSObject init method - correct? Not correct?
> 
> Not correct. If I understand correctly, the "New" is an old-fa****oned 
> form of creator and nowadays it's more fa****onable to use alloc and init

> instead. That doesn't mean that using New is wrong, or won't work.

Not quite. 'New' is a method Don invented; 'new' is an older factory 
method. Capitalization counts.

> However, your implementation of New above seems dodgy to me because I 
> think you're actually creating an NSObject since you're using 'super' to

> do the allocation.
> 
> I think you should be diong something like:
> 
>    DataGetter  *newGetter = [[DataGetter alloc] init];
>    return [newGetter autorelease];

Assuming 'New' is meant to be equivalent to 'new' the result shouldn't 
be autoreleased. A method named new is supposed to be functionally 
equivalent to an alloc/init sequence.

> > I'm still stuck back in "the dark ages" - X.3.9, running XCode 1.5, 
> > which I believe means I'm using Obj-C 1.something.
> 
> Then you're definitely not using garbage collection which means that 
> your code is like quicksand with mines. Some of your data will disappear

> when you least expect it and the rest will leak.

Until you come to grips with the memory contract which, bluntly, should 
take all of ten or 15 minutes. Read the ****tion of this page below the 
heading "How Memory Management Works"

<http://developer.apple.com/do***entation/Cocoa/Conceptual/CocoaFundament
als/CocoaObjects/chapter_3_section_5.html>

The over-simplified form is that you're responsible for releasing an 
object if and only if one of the following is true:
1. You received the object as a result of a new... message or an 
alloc/init... pair.
2. You received the object as the result of a message whose name 
contains the word copy.
3. You've sent a retain message to the object.
4. (very rare) The do***entation has specifically pointed out an 
exception whereby you need to do so.


G

-- 
"Harry?" Ron's voice was a mere whisper. "Do you smell something ...
burning?"
   - Harry Potter and the Odor of the Phoenix
 




 40 Posts in Topic:
I must be missing something... (Categories)
Don Bruder <dakidd@[EM  2008-05-13 08:37:26 
Re: I must be missing something... (Categories)
Tom Harrington <tph@[E  2008-05-13 10:18:36 
Re: I must be missing something... (Categories)
Gregory Weston <uce@[E  2008-05-13 13:44:52 
Re: I must be missing something... (Categories)
Don Bruder <dakidd@[EM  2008-05-13 11:10:55 
Re: I must be missing something... (Categories)
Gregory Weston <uce@[E  2008-05-13 13:44:44 
Re: I must be missing something... (Categories)
Don Bruder <dakidd@[EM  2008-05-13 11:36:45 
Re: I must be missing something... (Categories)
Gregory Weston <uce@[E  2008-05-13 15:28:22 
Re: I must be missing something... (Categories)
Gregory Weston <uce@[E  2008-05-13 15:41:52 
Re: I must be missing something... (Categories)
Don Bruder <dakidd@[EM  2008-05-13 14:54:17 
Re: I must be missing something... (Categories)
Gregory Weston <uce@[E  2008-05-13 18:04:18 
Re: I must be missing something... (Categories)
William Yeo <wcyeo@[EM  2008-05-13 15:14:21 
Re: I must be missing something... (Categories)
Don Bruder <dakidd@[EM  2008-05-13 16:02:00 
Re: I must be missing something... (Categories)
William Yeo <wcyeo@[EM  2008-05-13 16:41:09 
Re: I must be missing something... (Categories)
Don Bruder <dakidd@[EM  2008-05-13 18:15:56 
Re: I must be missing something... (Categories)
William Yeo <wcyeo@[EM  2008-05-13 21:38:25 
Re: I must be missing something... (Categories)
Gregory Weston <uce@[E  2008-05-14 07:28:07 
Questions about memory management (was Re: I must be missing som
Don Bruder <dakidd@[EM  2008-05-23 11:01:11 
Re: Questions about memory management (was Re: I must be missing
Gregory Weston <uce@[E  2008-05-23 17:22:47 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-23 20:20:10 
Re: Questions about memory management (was Re: I must be missing
William Yeo <wcyeo@[EM  2008-05-23 20:59:14 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-23 21:49:26 
Re: Questions about memory management (was Re: I must be missing
Gregory Weston <uce@[E  2008-05-24 09:01:37 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-24 22:06:12 
Re: Questions about memory management (was Re: I must be missing
Gregory Weston <uce@[E  2008-05-25 08:29:49 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-25 11:23:08 
Re: Questions about memory management
Sherman Pendley <spamt  2008-05-25 17:34:26 
Re: Questions about memory management (was Re: I must be missing
William Yeo <wcyeo@[EM  2008-05-24 13:11:43 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-24 22:20:17 
Re: Questions about memory management (was Re: I must be missing
William Yeo <wcyeo@[EM  2008-05-24 23:37:13 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-25 10:22:16 
Re: Questions about memory management (was Re: I must be missing
William Yeo <wcyeo@[EM  2008-05-25 10:59:31 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-25 11:43:32 
Re: Questions about memory management (was Re: I must be missing
Gregory Weston <uce@[E  2008-05-25 15:27:50 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-25 13:07:37 
Re: Questions about memory management (was Re: I must be missing
Gregory Weston <uce@[E  2008-05-26 07:30:16 
Re: Questions about memory management (was Re: I must be missing
Don Bruder <dakidd@[EM  2008-05-26 07:30:02 
Re: Questions about memory management (was Re: I must be missing
glenn andreas <gandrea  2008-05-25 18:53:55 
Re: Questions about memory management (was Re: I must be missing
Gregory Weston <uce@[E  2008-05-24 08:57:32 
Re: I must be missing something... (Categories)
Matthias Benkard <usen  2008-05-14 15:26:05 
Re: I must be missing something... (Categories)
Matthias Benkard <mulk  2008-05-13 12:20:27 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 13 11:21:45 CDT 2008.