iOS-把JSON字符串转化为字典

释放双眼,带上耳机,听听看~!
#pragma mark - 通过我要学ID获取融云的Token---异步
- (void)getRongCloudTokenWith5151StudyID:(NSString *)studyID completed:(void(^)(NSString *IMToken))completed{
    NSString *url = [NSString stringWithFormat:@"users/%@/IMToken",studyID];
    [LFNetWorkManager requestDataBaseWithURLByGET:url parameters:nil isWithToken:NO completed:^(id responseObject) {
        NSString *dataStr = responseObject[@"data"];//JSON字符串
        NSData *jsonData = [dataStr dataUsingEncoding:NSUTF8StringEncoding];//转化为data
        NSDictionary *data = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:nil];//转化为字典
        NSInteger code = [responseObject[@"code"] integerValue];
        if (responseObject != nil && code==200) {
            if (completed){
                completed(data[@"token"]);
            }
        }else{
            if (completed){
                completed(nil);
            }
        }
    }];
}

 

人已赞赏
iOS文章

Storboard 使用UIScrollView做引导页

2019-10-29 7:35:34

iOS文章

iOS如何判断uiscrollview是向上滚动还是向下滚动

2019-10-29 9:33:19

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索