GitHub:https://github.com/zacaltman/ZAActivityBar
ZAActivityBar和SVProgressHUD非常相似,它提供了更加简洁的API来显示提示效果。
ZAActivityBar使用的动画效果来源于ZKBounceAnimation(https://github.com/khanlou/SKBounceAnimation),成功、失败的状态图标来源于Pictos(http://pictos.cc/)。
显示加载状态:
[ZAActivityBar showWithStatus:@"加载中..."];
显示成功、失败状态:
[ZAActivityBar showSuccessWithStatus:@"成功!"];[ZAActivityBar showErrorWithStatus:@"失败!"];
隐藏提示:
[ZAActivityBar dismiss];
官方: http://sbjson.org/
GitHub:https://github.com/stig/json-framework
API使用起来稍显繁琐,特别是初始化的时候:
@interface TestViewController ()<SBJsonStreamParserAdapterDelegate>
{
SBJsonStreamParser *parser;
SBJsonStreamParserAdapter *adapter;
}
// 冗长的初始化方法足以吓到一大片人
- (void)initSBJSON
{
// We don't want *all* the individual messages from the
// SBJsonStreamParser, just the top-level objects. The stream
// parser adapter exists for this purpose.
adapter = [[SBJsonStreamParserAdapter alloc] init];
// Set ourselves as the delegate, so we receive the messages
// from the adapter.
adapter.delegate = self;
// Create a new stream parser..
parser = [[SBJsonStreamParser alloc] init];
// .. and set our adapter as its delegate.
parser.delegate = adapter;
// Normally it's an error if JSON is followed by anything but
// whitespace. Setting this means that the parser will be
// expecting the stream to contain multiple whitespace-separated
// JSON documents.
parser.supportMultipleDocuments = YES;
}
#pragma mark SBJsonStreamParserAdapterDelegate methods
- (void)parser:(SBJsonStreamParser *)parser foundArray:(NSArray *)array
{
[NSException raise:@"unexpected" format:@"Should not get here"];
}
- (void)parser:(SBJsonStreamParser *)parser foundObject:(NSDictionary *)dict
{
NSLog(@"SBJson parser foundObject");
// 处理返回的数据
}
// 使用ASIHTTPRequest请求测试
- (void) loadData
{
__block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setRequestMethod:@"POST"];
[request setCompletionBlock:^{
// Use when fetching text data
//NSString *responseString = [request responseString];
// Use when fetching binary data
NSData *responseData = [request responseData];
NSLog(@"Connection didReceiveData of length: %u", responseData.length);
// Parse the new chunk of data. The parser will append it to
// its internal buffer, then parse from where it left off in
// the last chunk.
SBJsonStreamParserStatus status = [parser parse:responseData];
if (status == SBJsonStreamParserError)
{
NSLog(@"Parser error: %@", parser.error);
}
else if (status == SBJsonStreamParserWaitingForData)
{
NSLog(@"Parser waiting for more data");
}
}];
[request setFailedBlock:^{
NSError *error = [request error];
NSLog(@"failed - %@ %@", [error localizedDescription], error);
}];
[request startAsynchronous];
}
GitHub:https://github.com/johnezang/JSONKit
提供比SBJson更优异的性能以及更加简便的使用方法,但是中文最好使用utf-8格式(/uXXXX),否则容易造成乱码。
API调用起来非常简单,省去了SBJson那么一大堆的方法:
JSONDecoder* decoder = [[JSONDecoder alloc] initWithParseOptions:JKParseOptionNone]; id result = [decoder objectWithData:jsonData];
详细的使用方法请看它的GitHub主页。