-3

I do not have enough reputation to post an image.. so hopefully you will be able to help me through this. on the third line where is says "@implementation viewcontroller" my xcode is telling me this "@end is missing in implementation context" thanks in advance!

@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    mainInt = 0;
    randomMain = [NSTimer scheduledTimerWithTimeInterval:(1.0/1.0) target:self selector:@selector(randomMainvoid) userInfo:nil repeats:YES];
}


- (void)randomMainvoid {
    mainInt +=1;
    label.text = [NSString stringWithFormat:@"%d", mainInt];       
}    


- (IBAction)Start {
    [startButton setHidden:YES];
    timer = [NSTimer scheduledTimerWithTimeInterval:(0.0088) target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
    pos = CGPointMake(5.0, 6.0);
}
Firoze Lafeer
  • 17,133
  • 4
  • 54
  • 48
user2230366
  • 47
  • 1
  • 2
  • 1
    Please. ***Please.*** Grab a basic-level book on Objective-C, this is so fundamental that there's no excuse for asking this. (Also, a bit of common sense: if you are not telling the compiler that this is the end of the class, then how it is supposed to infer that?) –  Apr 02 '13 at 05:22
  • this is your second question which is going to close. And be sure your 3rd question is good enough, otherwise your account will be of **NO-Use**. – Anoop Vaidya Apr 02 '13 at 05:29
  • 3
    One great way to solve errors in syntax is to find code that works, and compare yours to it. If you're using Xcode, there are so many sample projects that are easy to download and double check your code against, if you don't do so you're really missing out. Also, read the compiler errors and crash reports - really try to understand them, they're not gibberish they actually are trying to communicate something to you! – Carl Veazey Apr 02 '13 at 05:30
  • @AnoopVaidya [He didn't.](http://stackoverflow.com/questions/15757056/missing-context-for-method-declaration) –  Apr 02 '13 at 05:56
  • @H2CO3: I again answerd there, and I hope will get hard earned +1 ;) – Anoop Vaidya Apr 02 '13 at 05:59

2 Answers2

2

At the end of @implementation ViewController you need @end

Your .m should look like this:

@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    mainInt = 0;
    randomMain = [NSTimer scheduledTimerWithTimeInterval:(1.0/1.0) target:self selector:@selector(randomMainvoid) userInfo:nil repeats:YES];
}


- (void)randomMainvoid {
    mainInt +=1;
    label.text = [NSString stringWithFormat:@"%d", mainInt];       
}    


- (IBAction)Start {
    [startButton setHidden:YES];
    timer = [NSTimer scheduledTimerWithTimeInterval:(0.0088) target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
    pos = CGPointMake(5.0, 6.0);
}

@end
Firoze Lafeer
  • 17,133
  • 4
  • 54
  • 48
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
  • Yap, +1 for full code. Perhaps an Amazon link to a good Objective-C book? :P –  Apr 02 '13 at 05:23
  • 2
    I don't know about the user, which country/language he use. He should also learn basic English, the error is straight forward **"@end is missing in implementation context"** – Anoop Vaidya Apr 02 '13 at 05:25
  • thanks for the help! after i did what you said i was given two more errors! they both say "Missing context for method declaration" what should i try now? – user2230366 Apr 02 '13 at 05:26
  • @AnoopVaidya And common sense too - and there's no book for that. –  Apr 02 '13 at 05:27
  • @user2230366: Show them, we will try to solve all your error :) – Anoop Vaidya Apr 02 '13 at 05:27
  • @user2230366 Very good. Now google those error messages and accept this answer. –  Apr 02 '13 at 05:27
0

After

- (IBAction)Start {
    [startButton setHidden:YES];
    timer = [NSTimer scheduledTimerWithTimeInterval:(0.0088) target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
    pos = CGPointMake(5.0, 6.0);
}

add @end

Anil
  • 2,430
  • 3
  • 37
  • 55