Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning iOS 4 Application Development
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 9th, 2012, 08:57 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 4 - viewDidLoad versus loadView

Hi all,

I'm currently working my way through the book using XCode 4. So far so good, but I do have a question now.
In the How it works explanation of the example on page 95 the author writes that you need to override the viewDidLoad method to programmatically create your view during runtime.
However in the example in chapter 3 on dynamically adding views he overrides the loadView method to build up the user interface.

Now I tried doing the same thing in this project. So instead of using viewDidLoad (works) I implement loadView. In that case I get a EXC_BAD_ACCESS error on this line: button.frame = frame;

When I add a call to the superclass in the first line of loadView, like this: [super loadView]; I no longer receive this error, but the author doesn't use this in the chapter 3 example. So my question is: what's the difference between those two methods and why does the author pick one over the other in those two examples?

Ruben.
Reply With Quote
  #2 (permalink)  
Old February 10th, 2012, 05:58 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

Have you read the documentation for -loadView? If not, check it out, and if you still have questions, I can try to expand on it.

Bob
Reply With Quote
  #3 (permalink)  
Old February 10th, 2012, 06:26 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Bob,

I haven't, but now I have. So if I understand correctly if you override loadView you need to create an actual view object and populate that with subviews. And viewDidLoad is called after loadView, so at that point the view is already loaded and you can add subviews to it.

What I don't get though is why I got the EXC_BAD_ACCESS error on that specific line (button.frame = frame) and why I don't get it when I first call the superclass implementation of loadView.

Thanks!

Ruben.
Reply With Quote
  #4 (permalink)  
Old February 10th, 2012, 08:27 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

Send me a copy of the project that is generating the error. It will be easier for me to diagnose if I don't have to speculate or make any assumptions about your code.
ipadhelper@me.com

Bob
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Correctness versus speed elwappo ASP.NET 3.5 Professionals 1 October 19th, 2011 05:54 AM
Comma Versus Dot Wenggo Javascript 6 March 1st, 2011 02:37 AM
chapter 5 : unicode versus ascii ew6014 BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 1 February 19th, 2010 12:08 AM
validateOnParse versus xsi:nil JaKKe XML 0 March 7th, 2006 06:23 AM



All times are GMT -4. The time now is 09:52 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.