Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • Here - differences in letter case - check all it's ok
  • Here - calling to method that not exist in .m file - check - exist
  • Here - same problem like in prev. question
  • Here - weird/non-standard setup Apple - all OK
  • Here - incorrect implementation
  • Here - missed parameter, so incorrect implementation
  • and other same errors...

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

like image 760
hbk Avatar asked Jul 20 '14 12:07

hbk


1 Answers

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.

like image 114
Salavat Khanov Avatar answered Nov 15 '22 03:11

Salavat Khanov