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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With