Wrox Programmer Forums
|
BOOK: Beginning iOS 4 Application Development
This is the forum to discuss the Wrox book Beginning iOS 4 Application Development by Wei-Meng Lee; ISBN: 978-0-470-91802-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS 4 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 17th, 2011, 11:06 PM
Registered User
 
Join Date: May 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 3 - declaring a property

In chapter 3, the author has us declare the following property:

Code:
@property (nonatomic, retain) UITextField txtName;
Why declare this as a property of the controller? The text field is already a member of the view and can be accessed from the controller code. Is this a stylistic preference or does it have some functional value that I am missing?
 
Old May 18th, 2011, 10:43 AM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

There are a few useful discussions concerning IBOutlets as properties here
http://stackoverflow.com/questions/1...etain-iboutlet
and here
http://stackoverflow.com/questions/1...236985#1236985

The book program is a simple example, so there is not going to be a problem, but using accessors is generally a good idea to provide clarity about memory management. Also, as the use of views and their associated subviews becomes more sophisticated there will likely be times when alterations will be done programmatically (i.e. addition/removal of fields or buttons). Correctly used setters and getters minimize the chance for memory leaks.

Bob
The Following User Says Thank You to thepianoguy For This Useful Post:
Druzziel (May 18th, 2011)
 
Old May 18th, 2011, 01:50 PM
Registered User
 
Join Date: May 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks, thepianoguy. I've been following various simple examples trying to get my brain wrapped around XCode and iOS development; the link you provided will help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Implementing the NavigateURL Property, Chapter 8 ??? cjdphlx1 BOOK: Beginning ASP.NET 4 : in C# and VB 4 April 25th, 2011 09:57 AM
Chapter 8 Public Property ChuckASP BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 March 6th, 2010 12:04 PM
Code Error - Chapter 1 - Adding a Property cbesh2 BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 0 November 7th, 2008 11:29 PM
Chapter 4: Page 120 - Property value not valid. VeganMan BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 April 3rd, 2008 12:26 AM
Chapter 13, can not visit the public property Artistry BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 2 August 25th, 2005 02:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.