我正在使用Afnetworking版本3.0並嘗試加載一些數據。數據正確進入響應對象,我試圖在NSMutableArray
中解析。然而,這是崩潰給我錯誤 -應用程序崩潰日誌「警告:無法加載任何Objective-C類信息。」
「警告:無法加載任何Objective-C類信息,這將顯着降低可用類型信息的質量。」
我的數據解析類是以下各項
DataProcessing.h-
#import <Foundation/Foundation.h>
#import "Book.h"
#import <AFNetworking/AFHTTPSessionManager.h>
#import <MBProgressHUD/MBProgressHUD.h>
@interface DataProcessing : NSObject
-(void)getAllTheBooks;
-(void)setBookList:(NSMutableArray*)list;
-(NSMutableArray*)getBookList;
@end
DataProcessing.m:
#import "DataProcessing.h"
@interface DataProcessing(){
Book *individualBook;
}
@property(nonatomic, strong) NSMutableArray *bookList;
@property(nonatomic, strong) BookDetails *bookDetails;
@end
@implementation DataProcessing
-(void)getAllTheBooks{
NSMutableArray *bookList =[[NSMutableArray alloc]init];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:@"https://natasha....../items" parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSArray *bookCollectionArray = (NSArray*)responseObject;
for (NSDictionary *dict in bookCollectionArray) {
individualBook = [[Book alloc]init];
individualBook.bookID = [dict objectForKey:@"id"];
individualBook.bookLink = [dict objectForKey:@"link"];
individualBook.bookTitle = [dict objectForKey:@"title"];
[bookList addObject:individualBook];
}
[self setBookList:bookList];
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
-(void)setBookList:(NSMutableArray*)list{
self.bookList = [[NSMutableArray alloc]init];
self.bookList = list;
}
-(NSMutableArray*)getBookList{
return self.bookList;
}
@end
我的控制器的viewDidLoad
是以下事項
- (void)viewDidLoad {
[super viewDidLoad];
DataProcessing *processing = [[DataProcessing alloc]init];
[processing getAllTheBooks];
NSMutableArray *array = [processing getBookList];
NSLog(@"%@", array);
}
當它崩潰,它顯示是這樣的 -
任何人都可以請幫助?
Nop ...同樣的錯誤。 – Natasha
好吧,無論如何不需要重新初始化將不斷調用的方法內部的bookList屬性。這隻需要在類初始化的地方進行一次。 – Echizzle