我在MGTwitterEngine
应用中使用iOS
SDK。我正在尝试使用此方法检查用户是否正在关注其他用户:
- (NSString *)isUser:(NSString *)username1 receivingUpdatesFor:(NSString *)username2
{
if (!username1 || !username2) {
return nil;
}
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
[params setObject:username1 forKey:@"user_a"];
[params setObject:username2 forKey:@"user_b"];
NSString *path = [NSString stringWithFormat:@"friendships/exists.%@", API_FORMAT];
return [self _sendRequestWithMethod:nil path:path queryParameters:params body:nil
requestType:MGTwitterUpdatesCheckRequest
responseType:MGTwitterMiscellaneous];
}
此方法始终返回此格式但不相同的字符串:
CB4C097E-6740-4536-885E-BAF7D8A981FD
基本上最好是获得一个bolean值,我不清楚我将如何处理这个值。
任何想法?
**编辑 初始化_engine
的代码 _engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate: self];
_engine.consumerKey = kOAuthConsumerKey;
_engine.consumerSecret = kOAuthConsumerSecret;
答案 0 :(得分:1)
这是一个异步请求,您必须将您的类设置为MGTwitterEngine的委托,并在这些方法中获得结果,您必须在您的类中实现:
- (void)statusesReceived:(NSArray *)statuses forRequest:(NSString *)connectionIdentifier;
- (void)directMessagesReceived:(NSArray *)messages forRequest:(NSString *)connectionIdentifier;
- (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)connectionIdentifier;
- (void)miscInfoReceived:(NSArray *)miscInfo forRequest:(NSString *)connectionIdentifier;
您可以在MGTwitterEngineDelegate.h中阅读:
// These delegate methods are called after all results are parsed from the connection. If // the deliveryOption is configured for MGTwitterEngineDeliveryAllResults (the default), a // collection of all results is also returned.
您可以检查结果值。