开发者

cannot find protocol declaration custom protocol delegate iphone

Slowly but surely getting this delegation and protocol stuff on iphone but I cannot understand this error.

I have declared my protocol in my first viewcontroller.

In the second viewcontroller i try to add it at the top after i have imported it into the header file and it cannot find it. see my code below.

//SendSMS

#import <UIKit/UIKit.h>
#import "LoginPage.h"
#import "MessageOptions.h"

@protocol SMSProtocol <NSObject>

-(NSString *)postbackType;

@end


@interface S开发者_Python百科endSMS : UIViewController <UITextViewDelegate, UITextFieldDelegate> {

    id<SMSProtocol> delegate;

    MessageOptions *messageOptions;
    LoginPage *loginPage;
    IBOutlet UITextField *phonenumber;
    IBOutlet UITextView *smsBody;
    IBOutlet UIScrollView *scrollview;

}

@property (nonatomic, retain) id<SMSProtocol> delegate;

-(IBAction)LoadMessageOptions;

@end

Then my second view

#import <UIKit/UIKit.h>
#import "SendSMS.h"

@interface ScheduledSMS : UIViewController <SMSProtocol>{



}


-(IBAction)popBack;

@end


That is surely strange. Have you tried restarting Xcode? Xcode has a habit of not indexing symbols for me when I add new files.

You should also look into how your naming conventions. SendSMS is not really a good class name, more of a action method name. I would go for SendSMSViewController, since that is what it is.

By that it would follow that SMSProtocol should be named SendSMSViewControllerDelegate, since that is what it is.

Methods in a delegate protocol should contain the sender and one of the three words will, did, or should. If not at the very least it should name what it expects to return. -(NSString *)postbackType; should probably be -(NSString *)postbackTypeForSendSMSViewController:(SendSMSViewController*)controller;.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜