Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread mmalcolm crawford
On Nov 17, 2008, at 9:33 PM, Jeff Laing wrote: How about: http://developer.apple.com/samplecode/CacheInfo-MacOSX/listing1.html (for example) which has the IBOutlet tag on the instance variables rather than the properties; I'll bet its different because properties and instance vars have the

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Brian Stern
On Nov 19, 2008, at 3:59 AM, mmalcolm crawford wrote: On Nov 18, 2008, at 10:01 AM, Brian Stern wrote: OK Erik, I'll bite. What you describe above is correct as far as it goes. However, when you say all the memory management is handled in one place, of course it's two. The object has

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Greg Titus
On Nov 19, 2008, at 7:00 AM, Brian Stern wrote: This leaves us for now with two solutions: (a) Greg's (override setView:) which is more future-proof but is in many respects academically unsatisfying. (b) For non-top-level-object, specify an assign attribute for the property -- and risk

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Brian Stern
On Nov 19, 2008, at 10:29 AM, Greg Titus wrote: On Nov 19, 2008, at 7:00 AM, Brian Stern wrote: This leaves us for now with two solutions: (a) Greg's (override setView:) which is more future-proof but is in many respects academically unsatisfying. (b) For non-top-level-object, specify an

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Ricky Sharp
On Nov 19, 2008, at 10:13 AM, Brian Stern wrote: I think that you're probably right and that it's redundant. Needless to say, mmalc's best practice has the outlets being released in dealloc. That's why I had that code there in the first place. FWIW, I don't think that UIViewController

RE: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Jeff Laing
But if your dealloc is like this... - (void)dealloc { self.thisProp = nil; self.thatProp = nil; ... } then you'll be calling the accessors and the right thing will happen (i.e. release if necessary). This is what I currently do for all dev work (iPhone or Mac OS X).

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Brian Stern
On Nov 19, 2008, at 4:41 PM, Ricky Sharp wrote: From Apple's template code, didReceiveMemoryWarning does have these code comments generated: [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview // Release anything that's not essential, such as cached

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread mmalcolm crawford
On Nov 19, 2008, at 7:00 AM, Brian Stern wrote: There are competing issues. Following this best practice forces me to add public properties for all my outlets that my code never uses. This violates encapsulation and seems wasteful and error-prone. No, it's not. The nib-loading

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread j o a r
On Nov 19, 2008, at 1:57 PM, Jeff Laing wrote: My understanding (and I'm a noob in this) is that best practices recommend that you shouldn't start sending additional messages to an object from inside its dealloc. That is indeed correct. The official guideline is, AFAIK, to not call

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread mmalcolm crawford
On Nov 19, 2008, at 1:57 PM, Jeff Laing wrote: My understanding (and I'm a noob in this) is that best practices recommend that you shouldn't start sending additional messages to an object from inside its dealloc. Correct. (This is the one thing I hate the *most* about properties - they

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Brian Stern
On Nov 19, 2008, at 5:11 PM, j o a r wrote: On Nov 19, 2008, at 1:57 PM, Jeff Laing wrote: My understanding (and I'm a noob in this) is that best practices recommend that you shouldn't start sending additional messages to an object from inside its dealloc. That is indeed correct. The

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Michael Ash
On Wed, Nov 19, 2008 at 5:18 PM, mmalcolm crawford [EMAIL PROTECTED] wrote: On Nov 19, 2008, at 1:57 PM, Jeff Laing wrote: (This is the one thing I hate the *most* about properties - they really feel glued on, at this point, rather than being a language feature that the whole compiler knows

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread j o a r
On Nov 19, 2008, at 2:22 PM, Brian Stern wrote: That is indeed correct. The official guideline is, AFAIK, to not call through your properties in init / dealloc. For whatever reason UIViewController sets its view property to nil from its dealloc method. Greg's override of setView is based

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread mmalcolm crawford
On Nov 19, 2008, at 2:29 PM, Michael Ash wrote: On Wed, Nov 19, 2008 at 5:18 PM, mmalcolm crawford [EMAIL PROTECTED] wrote: On Nov 19, 2008, at 1:57 PM, Jeff Laing wrote: (This is the one thing I hate the *most* about properties - they really feel glued on, at this point, rather than

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread mmalcolm crawford
On Nov 19, 2008, at 1:57 PM, Brian Stern wrote: I'm starting to think that maybe using the assign properties is the better way to handle this. That's certainly one approach, and one that was considered. The problem is that you then have to think through every outlet declaration to make

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Ricky Sharp
On Nov 19, 2008, at 4:11 PM, j o a r wrote: On Nov 19, 2008, at 1:57 PM, Jeff Laing wrote: My understanding (and I'm a noob in this) is that best practices recommend that you shouldn't start sending additional messages to an object from inside its dealloc. That is indeed correct. The

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread j o a r
On Nov 19, 2008, at 3:05 PM, Ricky Sharp wrote: Now, when you say call through your properties in init/dealloc, is that explicitly for things set up with @property? Or, has what I've been doing all these years with calls to accessors in init/dealloc really bad? There's no difference

RE: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Jeff Laing
On Nov 19, 2008, at 2:29 PM, mmalcolm crawford wrote: You send a release message to instance variables for which there is a corresponding retain or copy property. which is why I originally said: (This is the one thing I hate the *most* about properties - they really feel glued on, at this

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Michael Ash
On Wed, Nov 19, 2008 at 5:41 PM, mmalcolm crawford [EMAIL PROTECTED] wrote: On Nov 19, 2008, at 2:29 PM, Michael Ash wrote: On Wed, Nov 19, 2008 at 5:18 PM, mmalcolm crawford [EMAIL PROTECTED] wrote: On Nov 19, 2008, at 1:57 PM, Jeff Laing wrote: (This is the one thing I hate the *most*

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-18 Thread Brian Stern
On Nov 18, 2008, at 2:12 AM, Jonathan Hess wrote: Which parts do you feel are contrary? I'm guessing it's that outlets with no setters are retained. Yes, that's the root of the whole issue. The fact is that outlets without setters that are retained aren't released by the code that

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-18 Thread Erik Buck
If you write correct accessors for all outlets, then the retain/release memory management is entirely handled in one method.  the -set retains the new value and releases the old value.   Any confusion regarding memory management for IB outlets seems to stem from failure to write the accessors

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-18 Thread Brian Stern
On Nov 18, 2008, at 9:15 AM, Erik Buck wrote: If you write correct accessors for all outlets, then the retain/ release memory management is entirely handled in one method. the - set retains the new value and releases the old value. Any confusion regarding memory management for IB outlets

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-18 Thread Greg Titus
Brian, The way to handle this is to _not_ respond to memory warnings in subclasses (at least not for the purposes of view outlet handling - there may be other non-view memory you want to free up in response to a memory warning). Instead, implement -setView: in your UIViewController

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-18 Thread Brian Stern
Thanks Greg, That does work and has no bad side effects. I can leave in the retain properties and release the outlets in the view controller's dealloc method. Thanks, Brian On Nov 18, 2008, at 1:19 PM, Greg Titus wrote: Brian, The way to handle this is to _not_ respond to memory

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Brian Stern
On Nov 17, 2008, at 9:11 PM, mmalcolm crawford wrote: One other consideration, particularly in iPhone applications, is where you might have outlets to subviews of a main view that might be released in sime situations -- e.g. a UIViewController whose view is released in

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Luke the Hiesterman
On Nov 17, 2008, at 7:12 PM, Brian Stern wrote: OK, this issue has come up for me very recently. It appears that on iPhoneOS IBOutlets are retained, regardless of the presence of properties. Even worse, in the presence of an assign property the outlet is still retained. Whatever code

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Brian Stern
On Nov 17, 2008, at 10:17 PM, Luke the Hiesterman wrote: On Nov 17, 2008, at 7:12 PM, Brian Stern wrote: OK, this issue has come up for me very recently. It appears that on iPhoneOS IBOutlets are retained, regardless of the presence of properties. Even worse, in the presence of an

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Brian Stern
On Nov 17, 2008, at 10:53 PM, Luke the Hiesterman wrote: On Nov 17, 2008, at 7:46 PM, Brian Stern wrote: On Nov 17, 2008, at 10:17 PM, Luke the Hiesterman wrote: On Nov 17, 2008, at 7:12 PM, Brian Stern wrote: OK, this issue has come up for me very recently. It appears that on

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Roland King
OK, this issue has come up for me very recently. It appears that on iPhoneOS IBOutlets are retained, regardless of the presence of properties. Even worse, in the presence of an assign property the outlet is still retained. Whatever code is retaining the outlets never releases them.

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Brian Stern
On Nov 17, 2008, at 11:05 PM, Roland King wrote: OK, this issue has come up for me very recently. It appears that on iPhoneOS IBOutlets are retained, regardless of the presence of properties. Even worse, in the presence of an assign property the outlet is still retained. Whatever

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Luke the Hiesterman
On Nov 17, 2008, at 8:15 PM, Brian Stern wrote: When you say I can manage the outlets any way I like this is wrong. They are managed for me. I want them to not be retained. I don't have that option. I never said this. I compared having objects unarchived from a nib to being alloc'd,

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Luke the Hiesterman
On Nov 17, 2008, at 8:17 PM, Brian Stern wrote: I think it makes more sense to release the Outlets in viewDidLoad. Why would you be releasing outlets when the view just loaded? Generally releasing happens when you're ready for something to go away

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Brian Stern
On Nov 17, 2008, at 11:20 PM, Luke the Hiesterman wrote: On Nov 17, 2008, at 8:17 PM, Brian Stern wrote: I think it makes more sense to release the Outlets in viewDidLoad. Why would you be releasing outlets when the view just loaded? Generally releasing happens when you're ready for

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Roland King
Yes, but this is exactly the point. If I have no property for an Outlet it's still retained. If I have a property for an outlet that is assign, and not retain the outlet is still retained, and I still must release it, even though I never retained it. When you say I can manage the

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread mmalcolm crawford
On Nov 17, 2008, at 7:12 PM, Brian Stern wrote: On Nov 17, 2008, at 9:11 PM, mmalcolm crawford wrote: One other consideration, particularly in iPhone applications, is where you might have outlets to subviews of a main view that might be released in sime situations -- e.g. a

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Brian Stern
On Nov 17, 2008, at 11:35 PM, Roland King wrote: Yes, but this is exactly the point. If I have no property for an Outlet it's still retained. If I have a property for an outlet that is assign, and not retain the outlet is still retained, and I still must release it, even though I

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread mmalcolm crawford
On Nov 17, 2008, at 8:05 PM, Roland King wrote: The iPhone version of nib unarchiving and hookup seemed very consistent to me, it makes use of properties or setFoo: if you have them, allowing you to manage objects any way you like. This applies to both iPhone and Mac OS X/desktop. This

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread mmalcolm crawford
On Nov 17, 2008, at 8:17 PM, Brian Stern wrote: I think it makes more sense to release the Outlets in viewDidLoad. This way I only have to release them in one spot, not two. No, it doesn't. There is no sense at all in releasing outlets in viewDidLoad. Follow the pattern I described and

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread mmalcolm crawford
On Nov 17, 2008, at 8:34 PM, Brian Stern wrote: Don't you find it odd that you need to release outlets in didReceiveMemoryWarning? Not at all -- assuming that you have a reference -- strong or weak -- to an item in the user interface, you want to make sure you break it if the view is

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Brian Stern
On Nov 17, 2008, at 11:51 PM, mmalcolm crawford wrote: On Nov 17, 2008, at 7:12 PM, Brian Stern wrote: On Nov 17, 2008, at 9:11 PM, mmalcolm crawford wrote: One other consideration, particularly in iPhone applications, is where you might have outlets to subviews of a main view that might

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Roland King
Brian Stern wrote: On Nov 17, 2008, at 11:35 PM, Roland King wrote: Yes, but this is exactly the point. If I have no property for an Outlet it's still retained. If I have a property for an outlet that is assign, and not retain the outlet is still retained, and I still must

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Luke the Hiesterman
On Nov 17, 2008, at 9:10 PM, Brian Stern wrote: I simply don't need properties for all my Outlets, except for this issue. I also don't really like making all my outlets implicitly public. But I'm forced to do that. You can use the readonly option for your properties. Alternatively,

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Luke the Hiesterman
On Nov 17, 2008, at 9:11 PM, Roland King wrote: I'm a bit limited at work, no Mac here, so I took a look with wordpad .. how nice. You've defined the actual label pointers as IBOutlet, like this IBOutlet MyLabel* mLabel1; and then called the properties label1 etc. in your .h file. When

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread mmalcolm crawford
On Nov 17, 2008, at 8:53 PM, Brian Stern wrote: Here's my test project: http://bellsouthpwp2.net/b/r/brians99/projects/TestPropertiesAndOutlets.zip There are three labels that are outlets. One has a retain property, one an assign property, and the third no property. Unless they are

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Brian Stern
On Nov 18, 2008, at 12:11 AM, Roland King wrote: Brian Stern wrote: On Nov 17, 2008, at 11:35 PM, Roland King wrote: Yes, but this is exactly the point. If I have no property for an Outlet it's still retained. If I have a property for an outlet that is assign, and not retain

RE: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Jeff Laing
If you declare a property: @property (nonatomic, assign) MyLabel *label1; but make the connection in IB to mLabel1, then the property accessor isn't used. So the outlet is set using setValue:forKey:. Which results in the value being retained, precisely as described in the

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Jonathan Hess
On Nov 17, 2008, at 10:12 PM, Brian Stern wrote: On Nov 17, 2008, at 9:11 PM, mmalcolm crawford wrote: One other consideration, particularly in iPhone applications, is where you might have outlets to subviews of a main view that might be released in sime situations -- e.g. a

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Brian Stern
On Nov 18, 2008, at 12:13 AM, mmalcolm crawford wrote: On Nov 17, 2008, at 8:53 PM, Brian Stern wrote: Here's my test project: http://bellsouthpwp2.net/b/r/brians99/projects/TestPropertiesAndOutlets.zip There are three labels that are outlets. One has a retain property, one an assign

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Jonathan Hess
Perhaps the new @property() syntax makes it easy to forget about object lifetimes because it does the set/get/change automagically. These days when I add any property I go right to the dealloc method (and init if I have one) and ensure I've managed that property before I forget. Yes, but

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Jonathan Hess
On Nov 18, 2008, at 1:11 PM, Roland King wrote: Brian Stern wrote: On Nov 17, 2008, at 11:35 PM, Roland King wrote: Yes, but this is exactly the point. If I have no property for an Outlet it's still retained. If I have a property for an outlet that is assign, and not retain

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Brian Stern
On Nov 18, 2008, at 12:34 AM, Jonathan Hess wrote: The solution to a memory leak should never be an unbalanced release. What I did to fix this was to add all of the properties to all of the outlets so they'd all be retained through those properties. Then I added all the releases to all

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Jonathan Hess
On Nov 18, 2008, at 12:49 AM, Brian Stern wrote: On Nov 18, 2008, at 12:35 AM, Jonathan Hess wrote: Normally instance variables and properties share the same name, Normally in your code maybe, not mine. so it doesn't matter to Interface Builder where the 'IBOutlet' text appears. If

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Jonathan Hess
On Nov 18, 2008, at 12:49 AM, Brian Stern wrote: On Nov 18, 2008, at 12:35 AM, Jonathan Hess wrote: Perhaps the new @property() syntax makes it easy to forget about object lifetimes because it does the set/get/change automagically. These days when I add any property I go right to the

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Brian Stern
On Nov 18, 2008, at 12:59 AM, Roland King wrote: Hey Brian - Outlets for iPhone OS are established by calling setValue:forKeyPath:. The behavior of setValue:forKeyPath: is that if a setter exists, it is called. If a setter does not exist, the instance variable is looked up and set

Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-17 Thread Jonathan Hess
On Nov 18, 2008, at 1:14 AM, Brian Stern wrote: On Nov 18, 2008, at 12:59 AM, Roland King wrote: Hey Brian - Outlets for iPhone OS are established by calling setValue:forKeyPath:. The behavior of setValue:forKeyPath: is that if a setter exists, it is called. If a setter does not