View Single Post
  #1 (permalink)  
Old June 23rd, 2013, 08:09 PM
Karl Karl is offline
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2013
Location: Queensland
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 6 Errors

Hello there,

I am new to programming and I'm getting on well with your book. I do find that there are some things which appear in the videos and downloaded code which differ greatly from what appears in my X Code. I put it down to differing versions of your XCode and mine. Sometimes I implement what XCode says I should do to correct the errors and sometimes I don't. I've got away with it so far, but now I'm stuck.

My Lesson6ViewController.h looks the same as yours,

My Lesson6ViewController.m has 8 errors and there is a lot of extra code in both the video and the downloaded example. Can you help, I would really appreciate your advice.
Here's the offending code, below.
Thanks, Karl.

OSX 10.7.5, XCode 4.6.3 (4H1503)


    NSString* username = usernameField.text;     ---Error "Use of  undeclared identifier 'usernameField'---                                                     
    int length = [username length];                  ---Error "Initializer element is not a compile-time constant---
    if (length == 0)                              ---Error "Expected identifier or'(' "---
    NSString* alertMessage = [NSString stringWithFormat:@"Welcome %@",     ---Error "Initializer element is not a compile-time constant---
        UIAlertView* welcomeMessage = [[UIAlertView alloc]    ---Error "Initializer element is not a compile-time constant----
                                       initWithTitle:@"Login Successful"

[welcomeMessage show];                               ---Error "Missing '[' at start of message send expression (3)"---

- (void) handleBackgroundTap:(UITapGestureRecognizer *)sender
    [usernameField resignFirstResponder];

#import <UIKit/UIKit.h>

@interface Lesson6ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *usernameField;
@property (weak, nonatomic) IBOutlet UITextField *passwordField;
- (IBAction)onDismissKeyboard:(id)sender;
- (IBAction)onLogin:(id)sender;
- (void) handleBackgroundTap:(UITapGestureRecognizer*)sender;

Reply With Quote