Basic errors

Discussion in 'iOS Programming' started by Kapthehat, Aug 6, 2013.

  1. Kapthehat, Aug 6, 2013
    Last edited: Aug 6, 2013

    Kapthehat macrumors member

    Joined:
    Jul 1, 2013
    #1
    I am working through Apress beginning IOS Development and am encountering some basic errors - which I can't seem to get my head around. These all relate to the project in chapter 6.0.

    I have attached some screenshots - which show the errors and code. All help gratefully appreciated. Thanks

    regards

    Kaps
     

    Attached Files:

  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    1) The Interface and Implementation should never be in the same file.
     
  3. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
    #3
    Basic errors

    Thanks - so which one do I need to remove ?
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Interface goes in the .h file, implementation in the .m. I'm pretty sure XCode will have set up the template/empty files like this anyway.
     
  5. Tander macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #5
    As above - the .h (header file) should never have an @implimentation in it. It is used for declaring properties and methods. No "executable code" should ever go in there.

    Think of the files like this:

    The .h file:

    This is like the index of a book - likes what the class is about - and it's properties

    The .m
    Is like a workshop manual - tells you how to do a set of instructions and the "working code" behind it.

    Examples:

    Code:
    header file.h 
    
    
    #import <UIKit/UIKit.h>
    
    @interface SomeClass : SomeSubClass
    
    @property (copy, nonatomic) IBOutlet UIButton *fooButton; 
    @end
    
    
    So now we know that this class has a UIButton named Foo - what does this button actually do?

    That's where our implementation file comes into play ...

    Code:
    
    #import "SomeClass.h"
    
    @implementation ViewController
    
    - (UIButton*)fooButton
    {
       //Puts up an alert view, saying hello 
    
      //Code in here to make that happen
    
    }
    
    
    @end
    
    
    

    I hope this clears up for issues a little and makes it clearer.
     
  6. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
    #6
    Thank you. I now have one error - stating that @end is missing in "BIDBlueViewController". See attached screenshots.
     
  7. Tander macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #7
    Right at the bottom of the class should have that - screen shot does't show the bottom of that class.


    Just make sure

    @end

    is the last line of code in that class.
     
  8. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
    #8
    basic errors

    Thanks everybody !!! got it working
     

Share This Page