[閒聊] 剛剛無聊寫的一段code

看板MacDev作者 (紙大師)時間12年前 (2012/05/17 22:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
最近臉書都被Diablo洗版 稍早看到朋友用別的語言貼了一個登入失敗的邏輯在酸 所以我也用OC寫了一個XD 編譯應該可以過 但是你要先找到header file XDDDD #import "DiabloIII.h" @interface DiabloIIILoginCheck : NSObject { BOOL mCanPlay; } -(BOOL)doChkAccountWithUid:(NSString*)uid andPwd:(NSString*)pwd forError:(NSError**)error; -(BOOL)canPlay; @end @implementation DiabloIIILoginCheck -(id)init { [self initWithUid:nil andPwd:nil forError:nil]; return self; } -(id)initWithUid:(NSString*)uid andPwd:(NSString*)pwd forError:(NSError**)error { self = [super init]; if(self) { mCanPlay = [self doChkAccountWithUid:uid andPwd:pwd forError:(NSError**)error]; } return self; } -(BOOL)doChkAccountWithUid:(NSString*)uid andPwd:(NSString*)pwd forError:(NSError**)error { BOOL result = NO; DiabloIII *diii = [DiabloIII getInstance]; if(![diii loginWithUid:uid andPwd:pwd]) { *error = [NSError errorWithDomain:@"ERROR" code:12 userInfo:nil]; goto EXIT; } switch ([diii getServer]) { case ASIA: *error = [NSError errorWithDomain:@"ERROR" code:3007 userInfo:nil]; break; case AMERICA: *error = [NSError errorWithDomain:@"ERROR" code:33 userInfo:nil]; break; case EUROPE: *error = [NSError errorWithDomain:@"ERROR" code:3003 userInfo:nil]; break; } EXIT: return result; } -(BOOL)canPlay { return mCanPlay; } @end -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.163.211.62
文章代碼(AID): #1FjGlZ5y (MacDev)