Search code examples
iosxcodexcode4syntax-error

XCODE protocol qualifiers without id is archaic


i'm a begginer xcode developer and usign the xcode 4 trying follow a xcode 3.2 tutorial the IDE show me the error;

protocol qualifiers without id is archaic

how i can solve it, what is the correct declaration

tutorial; http://www.youtube.com/watch?v=2Rd9TtG3Uws

code;

<UIPickerViewDataSource, UIPickerViewDelegate> {

    NSArray* activities;
    NSArray* fellings;
}

Solution

  • When you declare the interface, it inherits from a base class such as NSObject, UIView, UIViewController etc... You need the interface name, then the base class then the delegates it supports.

    Something like this:

    @interface MyView: UIView <UIPickerViewDataSource, UIPickerViewDelegate> {
        NSArray* activities;
        NSArray* fellings;
    }
    

    Also, if you're implementing an object that expects something that implements that protocol you should accept id in the signature. Fr example:

    - (id)initWithContext:(NSManagedObjectContext *)context
              coordinator:(NSPersistentStoreCoordinator *)coordinator
                 delegate:(id<NSFetchedResultsControllerDelegate>)delegate;
    

    See this SO question with the same error:

    What does this LLVM 1.5 warning mean? "protocol qualifiers without 'id' is archaic"