开发者

cannot find protocol declaration custom protocol delegate iphone

开发者 https://www.devze.com 2023-03-25 21:54 出处:网络
Slowly but surely getting this delegation and protocol stuff on iphone but I cannot understand this error.

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

精彩评论

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