2015-04-03 62 views
-2

我有這樣的NSArray方法在這裏:Objective-C的傳遞兩個參數爲布爾方法

-(NSArray*)User:(NSString *)user andPassWordExists:(NSString *)password 

,但我並不需要再返回一個數組,只是一個是或否,我將如何改變這個方法成BOOL方法?

-(BOOL*)User:(NSString *)user Password:(NSString *)password 

上面的代碼給了我這個錯誤:

Conflicting return type in implementation of User:Password: NSArray vs BOOL 

如何改變這種方法成一個布爾值?

+1

您需要在接口和實現中將其更改爲'BOOL',否'*')。 – Kevin 2015-04-03 01:36:36

回答

2

簽名應該是

-(BOOL)User:(NSString *)user Password:(NSString *)password 
在報頭和源文件

0
struct CheckinUser { 
    bool user:YES; 
    bool pwd:YES; 
}; 
typedef struct CheckinUser CheckinUser; 

-(CheckinUser)User:(NSString *)user Password:(NSString *)password 
{ 
    CheckinUser result; 
    result.user = YES; 
    result.pwd = NO; 
    return result; 
} 
+0

OP要返回BOOL – Drakes 2015-04-03 05:03:48