Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

iphonequestions

macrumors newbie
Original poster
Mar 21, 2010
14
0
hey guys,

I am just creating an app at the moment, im a bit new at this, and i have just one question, i think i can get the rest working. Im not sure if its a really easy question to answer but ill give it a go anyway.

I need to implement a protocol and i have no idea what to write, can anyone tell me what it would look like to implement a protocol for this error im getting?

warning: class 'FirstViewController' does not implement the 'SubstitutableViewController' protocol

I looked up the documentation and all i seen was

@protocol ProtocolName

method declarations

@end

But what should this look like given the error im getting?

Thank you for any help.
 
hey guys,

I am just creating an app at the moment, im a bit new at this, and i have just one question, i think i can get the rest working. Im not sure if its a really easy question to answer but ill give it a go anyway.

I need to implement a protocol and i have no idea what to write, can anyone tell me what it would look like to implement a protocol for this error im getting?

warning: class 'FirstViewController' does not implement the 'SubstitutableViewController' protocol

I looked up the documentation and all i seen was



But what should this look like given the error im getting?

Thank you for any help.

Well for one you should post some more code explaining it in further detail. secondly the FirstViewController is not implementing the methods the protocol outlined.
Example:
if myProtocol has two methods, add:(int)number and subtract:(int)number, then the class that is implementing it must have those methods, unless they are @optional.
 
The error says, that you need to specify the protocol on the interface that implements it, like so:

Code:
@interface Classname <Protocol,Protocol2> {
...
}
...
@end

HTH,
Christian
 
Well for one you should post some more code explaining it in further detail. secondly the FirstViewController is not implementing the methods the protocol outlined.
Example:
if myProtocol has two methods, add:(int)number and subtract:(int)number, then the class that is implementing it must have those methods, unless they are @optional.

The error says, that you need to specify the protocol on the interface that implements it, like so:

Code:
@interface Classname <Protocol,Protocol2> {
...
}
...
@end

HTH,
Christian



Ok, so would i put something like this in my code:
@interface SubstitutableViewController
- (void)FirstViewController;
@end

Or is this completely wrong? I put this in and it still says the same thing..
 
more like,
Code:
@interface FirstViewController<SubstitutableViewController> {
...
}
...
@end
 
more like,
Code:
@interface FirstViewController<SubstitutableViewController> {
...
}
...
@end

Thanks for the reply!!

But, what goes in the "..." areas?

When i wrote something like that i got an error saying "error: expected identifier or '(' before '{' token"?!
 
Asking such a question indicates you don't really have a handle on the basics of Objective-C. I would suggest you step away from the real coding for a while and go learn those basics.

I think that's a valid question for a beginner!!! I am trying to learn, as i said i read the documentation, but it DOES NOT say what to put in there... Just an empty 3 lines. It's a simple question (probably why your saying that) but that doesn't mean you can't answer it?!


Please, enlighten me as to what the basics are of this problem?

@interface FirstViewController<SubstitutableViewController> {
...
}
...
@end
 
in the @interface ClassName{ ... } spot you're putting your class member variables. Between the } and @end you're assigning properties and prototyping member functions.
 
I think that's a valid question for a beginner!!! I am trying to learn, as i said i read the documentation, but it DOES NOT say what to put in there... Just an empty 3 lines. It's a simple question (probably why your saying that) but that doesn't mean you can't answer it?!
My apologies if I came across harsh but I felt it needed to be said. What documentation have you read? The more info you can provide us of what you know, have read, etc. the better we can try to tailor our answers to your experience level.

Please, enlighten me as to what the basics are of this problem?
jhurley has answered this now. Hope you understand the answer.
 
I think that's a valid question for a beginner!!! I am trying to learn, as i said i read the documentation, but it DOES NOT say what to put in there... Just an empty 3 lines. It's a simple question (probably why your saying that) but that doesn't mean you can't answer it?!

I'd say the documentation is pretty clear an simple on this.

Core Cocoa Protocols

The definitive article

Each protocol will require a different number of lines with different content. It is important you understand what's going on in a general way, not specific to this protocol.

Before writing any code you should have read and fully understood all of the Core Cocoa documentation at the very least (I personally think this is probably tool little).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.