我遇到这个奇怪的问题,当我尝试NSLog
NSMutableArray
时,控制台只显示部分内容......这是我的代码:
+ (void)getCampgroundsWithServerURL:(NSString *)urlString
completionBlock:(void (^)(BOOL success, NSMutableArray *campgrounds))block {
NSURL *url = [NSURL URLWithString:[urlString stringByAppendingPathComponent:@"campgrounds"]];
//HTTP GET Request
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"GET";
[request addValue:@"campgrounds/json" forHTTPHeaderField:@"Accept"];
NSURLSessionConfiguration* config = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession* session = [NSURLSession sessionWithConfiguration:config];
NSURLSessionDataTask* dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error){
if (error == nil) {
//store the data into an array
NSMutableArray *CGs = [[NSMutableArray alloc]initWithArray:[NSJSONSerialization JSONObjectWithData:data options:0 error:NULL]];
block(YES,CGs);
NSLog(@"%@", CGs);
} else {
block(NO, nil);
}
}];
[dataTask resume];
}
这是控制台输出:
2016-10-16 12:24:36.492711 Yelp Camp[6452:1758068] (
{
"__v" = 0;
"_id" = 57bc60c10ae5a01100e265e6;
author = {
id = 57b9ce5df817403406fa58fb;
username = gellert;
};
comments = (
);
description = TestDescription;
image = TestURL;
name = Test;
},
{
"__v" = 2;
"_id" = 57bd7868730c321100db974b;
author = {
id = 57b9ce5df817403406fa58fb;
username = gellert;
};
comments = (
{
"__v" = 0;
"_id" = 57bd7896730c321100db974c;
author = {
id = 57b9ce5df817403406fa58fb;
username = gellert;
};
text = "\U6f02\U4eae";
},
{
"__v" = 0;
"_id" = 57bd78b3730c321100db974e;
author = {
id = 57bd78a3730
显然它只打印了阵列的一半......怎么可能? NSLog
是否有长度限制?
注意:我的数据库或服务器完全没问题。