 |
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
|
|
|
|

February 10th, 2011, 10:59 PM
|
|
Registered User
|
|
Join Date: Feb 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
New to Programming
Hello. I am up to page 36 in Hello world. I have followed the step by step guide, but for some reason the iOS simulator does not show the icon for Hello World. Also, after putting in all the codes for h and m, the Hello World button clicked will not work. Any suggestions? I am going to re-run the steps from the beginning to see if I missed something.
Also, I am noticing that the book is a little different that the screens I am seeing. I am runnign 4.2. Can you help?
|
|

February 11th, 2011, 09:01 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
|
|
Without seeing you code, it is impossible to try and diagnose any errors. Copy and paste the code into a reply.
I don't have this book, but do have the prior book by the author, with many of the same projects, so I can't address possible omissions in the current book's text. In the prior book one step that was frequently omitted was the need to save changes after working in Interface Builder (i.e. connect an outlet and/or action and now return to Xcode without mentioning "Save your work" before returning to Xcode.) Saving changes in IB must be done for Xcode to know about them.
If you post your code and everything looks good, the problem will most likely be related to an unsaved outlet or action connection.
A way to check connections while running the program is to insert NSLog statements in the action methods (or any method you want to verify is being called) and have the console log open as you run the program. This way you can trace the flow of the program.
Bob
|
|

February 11th, 2011, 11:09 PM
|
|
Registered User
|
|
Join Date: Feb 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for helping me
I tried another shot at making making the outlet and actions project work, but no luck. Is this book outdated, because the code is not turning the right color as it is in the book. Here is the code from .h and.m. For some reason the *txtName is not turning green and anything with a * is not turning the right color. Also, dealloc and str is being flagged.
#import <UIKit/UIKit.h>
@interface OutletsAndActionsViewController : UIViewController {
//---declaring the outlet---
IBOutlet UITextField *txtName;
}
//---expose the outlet as a property---
@property (nonatomic, retain) UITextfield *txtName;
//---declaring the action---
-(IBAction) btnClicked:(id) sender;
@end
from .m:
#import "OutletsAndActionsViewController.h"
@implementation OutletsAndActionsViewController
//---synthesize the property---
@synthesize txtName;
//---displays an alert view when the button is clicked---
-(IBAction) btnClicked:(id) sender {
NSString *str = [[NSString alloc]
initWithFormat:@"Hello, %@", txtName.text];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Hello!"
message:str
delegate:self
cancelButtonTitle:@"Done"
otherButtonTitles:nil];
[alert show];
[str release];
[alert release];
}
- (void)dealloc {
//---releasing the outlet---
[txtName release];
[super dealloc];
}
|
|

February 11th, 2011, 11:44 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
|
|
The code you have provided doesn't compile without errors because of a typo
@property (nonatomic, retain) UITextfield *txtName;
Should be
@property (nonatomic, retain) UITextField *txtName;
I set up a project, copy and pasted your code into it, fixed that typo, set up the view in Interface Builder, compiled ran and everything is fine.
Fix that typo and see if it runs.
If not email the project files to
[email protected]
and I will debug.
Bob
|
|

February 12th, 2011, 07:56 AM
|
|
Registered User
|
|
Join Date: Feb 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Any advice
Thanks so much for your help. It was a simple stupid mistake and that the book never told me to push "Build and run." then two errors popped up and I followed the code perfectly, so I am not sure what to do at this point. I will send it to you for debugging.
My future problem is not interface builder or designing the programs, but coding. HTML, CSS and Java are easy to understand, but Cocoa is out there. I have been looking for a site where I can get codes to cut and paste for certain actions, but I can not find any. Do you know any? Also, I have programmed tons of websites, by using other people's source codes and changing them to what I want. Is there a way to get a source code for .h and .m for an app? You have been a great help.
|
|

February 12th, 2011, 09:29 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
|
|
I will be happy to check out the issues with your project. It is easier to do from the actual project, so sending it is the best suggestion. Visual inspection is slower than compiling and using errors and warnings to spotlight errors, and potential problems stemming from Interface Builder are not visible in code.
I have never looked for 'sources' of source code. There are many projects included with the developer tools, and on Apple's developer site. These can be modified.
A good understanding of Objective C 2.0 and the Foundation Classes is essential in making smooth progress, in my opinion. Having experience and success at writing backend code in the Xcode environment will help with the move into the interface aspects. If you don't know Obj C, haven't used Xcode and are diving into iOS or Cocoa frameworks all at the same time it will be overwhelming. Fortunately Obj C is not that hard to learn, and Java, which you said you have used, borrows a number of concepts from it (with different names). Setting up working outlets and actions will not be hard once you have successfully done it a couple of times.
The next thing is to grasp the concept of delegates, and read the documentation to find out what existing objects already know how to do. After this, using the generic controllers and bindings is the next step.
The best resource for Objective C 2.0 is from a different publisher, and I would be happy to PM or email the title and support site link to you.
If you send the project, I should be able to find out where you took a wrong turn and hopefully steer you in the right direction. I have a rehearsal most of the day so, may not get back to you immediately.
Also, I don't have this book but do have the prior version, from which many of the projects have been recycled. You mentioned that the Build and Run step was omitted. The earlier book does say Press Command-R which is the same as Build and Run.
Bob
|
|

February 12th, 2011, 01:02 PM
|
|
Authorized User
|
|
Join Date: Feb 2011
Posts: 13
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
"best resource for Objective C 2.0"
@thepianoguy
Bob, I'd be very interested to hear your recommendation.
Do you really think wrox would be uptight about mentioning it in the open?
Seems like the feedback would be useful for them, maybe motivation to come up w/ something better!
thx!
|
|

March 23rd, 2011, 12:18 AM
|
|
Registered User
|
|
Join Date: Mar 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Bob, I was reading your pos about learning Xcode, Obj C, iOS, Cocoa Frameworks, etc. I would be unterested to hear your recommendations, in what/how to learn, as most of this is new to me..... I have worked through some Unix/Terminal/Mac books is about all, and I'm interested in iOS app development.
I am currently working through the Beginning iOS 4 Application Development Book
Thank You!
Mike
|
|
 |
|