On May 20, 2010, at 7:40 am, Thomas Davie wrote:
>> However, you should typically not invoke accessor methods in init or dealloc
>> methods.
>
> Can I ask why you shouldn't use them in init? It makes a lot of sense to not
> use them in alloc/dealloc, but I'm not using them in init... after al
On Thu, May 20, 2010 at 9:27 AM, Dave Keck wrote:
> I'm not a fan of isInitialized either, but even less enthralled by
> duplicated code. Furthermore, couldn't one make the case that a class
> that's well-fit for subclassing has exactly one technique for setting
> a property (the setter), giving s
> You can get away with a lot of things if you don't care about writing
> subclass-tolerant code. But since I don't have a crystal ball, I don't
> write code which I know will require hacky "isInitialized" flags to be
> correct.
I'm not a fan of isInitialized either, but even less enthralled by
du
On Thu, May 20, 2010 at 8:27 AM, Dave Keck wrote:
> Which could be solved with a simple if-statement within the subclass'
> -setContent:, allowing you to use accessors everywhere to avoid code
> duplication and giving your subclasses full control over the setting
> of the content property.
You ca
> I'll give you a concrete example. We have an NSController-like class that
> lives in a framework. Its designated intializer is -initWithContent:. In one
> of our apps, we have a subclass of this whose initializer is
> -initWithDocument:, and which uses the document to figure out its content.
> It
On May 20, 2010, at 9:47 AM, Thomas Davie wrote:
>
> On 20 May 2010, at 15:45, Barry Skidmore wrote:
>
>> If you need to have it set you should create an initWithOptionName: and call
>> that from your standard init, or return an error stating a missing value is
>> needed.
>>
>> Your init sho
On May 20, 2010, at 7:40 AM, Thomas Davie wrote:
Can I ask why you shouldn't use them in init? It makes a lot of
sense to not use them in alloc/dealloc, but I'm not using them in
init... after all, what if I replace the ivar with a derived
property from another object? Why should I have t
Ah I see. Not that I am aware of, in fact if you require a set
property in your object then init is the best place for it to be.
Sent from my iPhone
On May 20, 2010, at 9:47 AM, Thomas Davie wrote:
On 20 May 2010, at 15:45, Barry Skidmore wrote:
If you need to have it set you should cre
On 20 May 2010, at 15:45, Barry Skidmore wrote:
> If you need to have it set you should create an initWithOptionName: and call
> that from your standard init, or return an error stating a missing value is
> needed.
>
> Your init should always call down tithe most specific init.
>
> Specific e
If you need to have it set you should create an initWithOptionName:
and call that from your standard init, or return an error stating a
missing value is needed.
Your init should always call down tithe most specific init.
Specific examples of this are available as best practice in several
c
On 20 May 2010, at 15:24, mmalc Crawford wrote:
>
> On May 19, 2010, at 4:38 am, Sherm Pendley wrote:
>
>> If you set the ivars directly, as above, the synthesized setters will
>> NOT be called. For that to happen, you need to use dot-syntax, like
>> this:
>>
>> - (void) dealloc {
>> self.be
On May 19, 2010, at 1:48 am, Sai wrote:
> 1. Look at the awakeFromNib method of Controller, my output of the retain
> count to the console are
> myModel retain count: 5
> controller retain count: 17
> both number are very surprised me, why is that? I suppose they should be 2
> or 1?
> Can anyone
On May 19, 2010, at 4:38 am, Sherm Pendley wrote:
> If you set the ivars directly, as above, the synthesized setters will
> NOT be called. For that to happen, you need to use dot-syntax, like
> this:
>
> - (void) dealloc {
>self.beginButton = nil;
>self.endButton = nil;
>// etc...
>
On Thu, May 20, 2010 at 5:44 AM, Joanna Carter
wrote:
> Le 20 mai 2010 à 13:24, Alexander Spohr a écrit :
> Yes, because the ivar is synthesised, addressing myFoo would send the release
> message to the property, which is not recommended.
No. "Send the release message to the property" is a meani
Le 20 mai 2010 à 13:24, Alexander Spohr a écrit :
> Why not just using myFoo without the self->?
> To make it visible that you talk to an ivar?
Yes, because the ivar is synthesised, addressing myFoo would send the release
message to the property, which is not recommended.
Apparently, self->myFo
Am 19.05.2010 um 19:12 schrieb Kyle Sluder:
> On Wed, May 19, 2010 at 4:38 AM, Sherm Pendley
> wrote:
> If you synthesize your ivars, you can get at the ivar using the self-> syntax.
>
> self->myFoo = [aFoo retain];
> [self->myFoo release];
Why not just using myFoo without the self->?
To ma
On Wed, May 19, 2010 at 4:38 AM, Sherm Pendley wrote:
> If you set the ivars directly, as above, the synthesized setters will
> NOT be called. For that to happen, you need to use dot-syntax, like
> this:
But you shouldn't be using accessors in -init or -dealloc anyway. It
makes subclassing fragil
Hi Sherm
> If you set the ivars directly, as above, the synthesized setters will
> NOT be called. For that to happen, you need to use dot-syntax, like
> this:
You are absolutely right. I keep slipping back to previous languages :-)
Joanna
--
Joanna Carter
Carter Consulting
On Wed, May 19, 2010 at 6:31 AM, Joanna Carter
wrote:
> Any outlets for controls (top level objects) in the Nib should be released in
> the dealloc method only for OS X apps but not for iPhone apps. Setting the
> properties to nil will ensure that the synthesized setter will be called,
> which
Hi Guys
Can I just suggest something more?
> @interface Controller : NSObject {
>IBOutlet UIButton *beginButton;
>IBOutlet UIButton *endButton;
>IBOutlet UILabel *nameLabel;
>IBOutlet UILabel *numberLabel;
>MyModel *myModel;
> }
>
> @property (nonatomic, retain) IBOutlet MyMo
On Wed, May 19, 2010 at 11:17 AM, Sai wrote:
> Hi Jack,
> Thank you for your quick response. Your answer is very useful.
> Since I have pasted some of my codes in the previous mail. I just
> wonder if you have any comments on my codes, anything I can
> improve for this little app? Any advice will
Hi Jack,
Thank you for your quick response. Your answer is very useful.
Since I have pasted some of my codes in the previous mail. I just
wonder if you have any comments on my codes, anything I can
improve for this little app? Any advice will be very appreciated.
On Wed, May 19, 2010 at 5:07 PM,
On Wed, May 19, 2010 at 10:48 AM, Sai wrote:
> I have two questions:
> 1. Look at the awakeFromNib method of Controller, my output of the retain
> count to the console are
> myModel retain count: 5
> controller retain count: 17
> both number are very surprised me, why is that? I suppose they shoul
Hi all,
I have gone through the Memory Management Programming Guide document last
night, and modify my codes a little bit.
Even the program runs well without crashing, but I still have some questions
remained. I will attach some of my codes as
follow:
1. I have both Controller Object and MyModel
On May 18, 2010, at 1:20 PM, Sai wrote:
> Anyway, why I should retain that?
Because otherwise it will get autoreleased, but your instance variable will
still contain its address, and the next time you try to use it via the instance
variable, you will try to talk with random memory at that addre
On May 18, 2010, at 4:20 AM, Sai wrote:
Hi all,
Thanks for your reply. I didn't retain that, I will try that as soon
as I
get home.
Anyway, why I should retain that? Will it be released by "somebody"?
Re-read the Memory Management Programming Guide until you know the
rules backwards and
Hi all,
Thanks for your reply. I didn't retain that, I will try that as soon as I
get home.
Anyway, why I should retain that? Will it be released by "somebody"? Can
anyone tell me the whole process and what's going on please? I want to know
what happened. Thanks a lot.
On Tue, May 18, 2010 at 7:0
On Tue, May 18, 2010 at 12:40 PM, Sai wrote:
> However, I declare a NSDictionary instance variable in my model object. This
> NSDictionary instance
> store some data I need. And I will create this NSDictionary instance by
> invoking:
> [NSDictionary dictionaryWithObjects:names forKeys:keys]
Are y
Am 18.05.2010 um 12:40 schrieb Sai:
> Unfortunately, when I try to get value from that NSDictionary, I will get
> exc_bad_access signal, and I follow gdb, the NSDictionary instance seems to
> be corrupted.
> So where does it go wrong? Hopefully I state things clearly this time. Thank
> you all.
Hi Sal
> However, I declare a NSDictionary instance variable in my model object. This
> NSDictionary instance
> store some data I need. And I will create this NSDictionary instance by
> invoking:
> [NSDictionary dictionaryWithObjects:names forKeys:keys]
> Both names and keys are string NSArray. I
Hi,
Sorry I haven't given full details. I just found where the exc_bad_access
signal comes from.
I have a controller object and a model object, both are created in the
interface builder. So I suppose
they are stored in the XIB document. That's why they are initialized
automatically as you guys men
On May 17, 2010, at 12:33 AM, Quincey Morris wrote:
> Your Model is being initialized because the NIB file that contains it is
> being loaded. The gory details of what happens can be found here:
>
>
> http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/LoadingResources/
On May 15, 2010, at 10:56, Sai wrote:
> Suppose I have an iPhone application follow
> the MVC design pattern.
> The Model is presented by an custom object. And I have declared an instance
> of the Model Object as a IBOutlet
> in my Controller class. I found that every time I start my application,
On May 15, 2010, at 10:56 AM, Sai wrote:
> Hi All,
> I am new to cocoa development. Suppose I have an iPhone application follow
> the MVC design pattern.
> The Model is presented by an custom object. And I have declared an instance
> of the Model Object as a IBOutlet
> in my Controller class.
On
Hi All,
I am new to cocoa development. Suppose I have an iPhone application follow
the MVC design pattern.
The Model is presented by an custom object. And I have declared an instance
of the Model Object as a IBOutlet
in my Controller class. I found that every time I start my application, this
insta
35 matches
Mail list logo