hbk
hbk

Reputation: 11184

Method definition not found in Xcode

using Xcode 5.1, Objective-C

Just start to try use of Objective-C, write a simple program, and got some Warning :

Method definition for "some method" not found...

I'm looking in to my code and I see method in implementation file (.m) Screen.

image of warning

I know - see a lot of similar questions:

So according to this post, I think that the problem is or in missing declaration/implementation or some syntax's error

Check my code looks like all is ok.


Declaration - in .h file

//- mean non static method
//(return type) Method name : (type of var *) name of var
- (void)addAlbumWithTitle : (NSString *) title
//global name of var : (type of var *) local name of var
               artist : (NSString *) artist :
              summary : (NSString *) summary :
                price : (float) price :
      locationInStore : (NSString *) locationInStore;

Implementation in .m file

- (void)addAlbumWithTitle:(NSString *)title
               artist:(NSString *)artist
              summary:(NSString *)summary
                price:(float)price
      locationInStore:(NSString *)locationInStore {
Album *newAlbum = [[Album alloc] initWithTitle:title
                                        artist:artist 
                                       summary:summary 
                                         price:price  
                               locationInStore:locationInStore];
[self.albumList addObject:newAlbum];
}

I'm just few a day like start to try Objective-C with Xcode, maybe I something missed

Upvotes: 5

Views: 11801

Answers (1)

Salavat Khanov
Salavat Khanov

Reputation: 4198

The syntax is incorrect. Your .h should look like this for this method (remove extra colons):

- (void)addAlbumWithTitle:(NSString *)title
               artist:(NSString *)artist
              summary:(NSString *)summary
                price:(float)price
      locationInStore:(NSString *)locationInStore;

Apple Docs:

If you need to supply multiple parameters, the syntax is again quite different from C. Multiple parameters to a C function are specified inside the parentheses, separated by commas; in Objective-C, the declaration for a method taking two parameters looks like this:

- (void)someMethodWithFirstValue:(SomeType)value1 secondValue:(AnotherType)value2;

In this example, value1 and value2 are the names used in the implementation to access the values supplied when the method is called, as if they were variables.

Refer to the documentation.

Upvotes: 10

Related Questions