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

iLoveDeveloping

Suspended
Original poster
Sep 24, 2009
596
2,366
Ireland
Hey,

I'm trying to get a new view in my app to work, but I'm getting an error when i run it!

error: cannot find protocol declaration for 'SubstitutableViewController'

I went to the documentation and seen this,

Declaring a Protocol

You declare formal protocols with the @protocol directive:

@protocol ProtocolName

method declarations

@end

But, i have no idea how to write this in the app?! Someone said i might need to create an instance for SubstitutableViewController but im not sure what it is i have to do exactly? Anyone have any answers? Or example of what this should look like?


Thanks for any help...
 
A protocol declaration is a lot like a class declaration. There are also a bunch of them in the Apple headers. Look at those and model yours after one of them.

Typically it goes into a header file after the class declaration of the class that is related to it. You usually have a forward declaration before that class declaration because it needs to see the protocol declaration in order to declare its delegate. If you like the protocol declaration can go before the class declaration in the header file. Then any classes that need to know about the protocol declaration will import that header.

Open the multiple find window in Xcode. Type @protocol in the Find box. Choose 'In Frameworks' and click Find. You'll see over 20 examples.
 
A protocol declaration is a lot like a class declaration. There are also a bunch of them in the Apple headers. Look at those and model yours after one of them.

Typically it goes into a header file after the class declaration of the class that is related to it. You usually have a forward declaration before that class declaration because it needs to see the protocol declaration in order to declare its delegate. If you like the protocol declaration can go before the class declaration in the header file. Then any classes that need to know about the protocol declaration will import that header.

Open the multiple find window in Xcode. Type @protocol in the Find box. Choose 'In Frameworks' and click Find. You'll see over 20 examples.


Ok i put in "@protocol SubstitutableViewController;" and the app launches, but it crashes right away.. I looked in the console and it is saying:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'

What does this mean? It is looking for the dataSource for the table view?
 
Seems to be so. What dataSource is your UITableView is connected to? Can you please describe your project in a bit more detail? Seems like your protocol issue is fixed though.
 
It can be fixed, it means when you the cellForRowAtIndexPath, the cell returned is nil. How is cellForRowAtIndexPath declared in your project?
 
Your cellForRowAtIndexPath method has a bug. It is returning nil when it should be returning a valid cell. Show your code for this method.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.