版本判断 字典转字符串
来源:互联网 发布:成本会计 知乎 编辑:程序博客网 时间:2024/06/05 10:05
// 字典转字符串
- (NSString*)dictionaryToJson:(NSDictionary *)dic
{
NSError *parseError = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
// 版本判断
-(void)onCheckVersion:(NSString *)currentVersion
{
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
CFShow(infoDictionary);
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
NSString *URL = @"http://itunes.apple.com/lookup?id=APPID";
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:URL]];
[request setHTTPMethod:@"POST"];
NSHTTPURLResponse *urlResponse = nil;
NSError *error = nil;
NSData *recervedData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
NSString *results = [[NSString alloc] initWithBytes:[recervedData bytes] length:[recervedData length] encoding:NSUTF8StringEncoding];
NSDictionary *dic = [results JSONValue];
NSArray *infoArray = [dic objectForKey:@"results"];
if ([infoArray count]) {
NSDictionary *releaseInfo = [infoArray objectAtIndex:0];
NSString *lastVersion = [releaseInfo objectForKey:@"version"];
if (![lastVersion isEqualToString:currentVersion]) {
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"更新" message:@"有新的版本更新,是否前往更新?" delegate:self cancelButtonTitle:@"关闭" otherButtonTitles:@"更新", nil] autorelease];
alert.tag = 100;
[alert show];
}
}
}
- (NSString*)dictionaryToJson:(NSDictionary *)dic
{
NSError *parseError = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
// 版本判断
-(void)onCheckVersion:(NSString *)currentVersion
{
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
CFShow(infoDictionary);
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
NSString *URL = @"http://itunes.apple.com/lookup?id=APPID";
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:URL]];
[request setHTTPMethod:@"POST"];
NSHTTPURLResponse *urlResponse = nil;
NSError *error = nil;
NSData *recervedData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
NSString *results = [[NSString alloc] initWithBytes:[recervedData bytes] length:[recervedData length] encoding:NSUTF8StringEncoding];
NSDictionary *dic = [results JSONValue];
NSArray *infoArray = [dic objectForKey:@"results"];
if ([infoArray count]) {
NSDictionary *releaseInfo = [infoArray objectAtIndex:0];
NSString *lastVersion = [releaseInfo objectForKey:@"version"];
if (![lastVersion isEqualToString:currentVersion]) {
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"更新" message:@"有新的版本更新,是否前往更新?" delegate:self cancelButtonTitle:@"关闭" otherButtonTitles:@"更新", nil] autorelease];
alert.tag = 100;
[alert show];
}
}
}
0 0
- 版本判断 字典转字符串
- 字典转字符串,字符串转字典
- [iOS]字符串转字典
- 字符串转字典,setViewControllers
- 字典转json字符串
- 字符串转字典类型
- iOS 字符串转字典
- 字符串处理——iOS版本判断
- Objective-C 字符串、数组、字典及类型判断
- json字符串转字典,字典转json字符串
- iOS_Json字符串转字典、字典转成Json字符串
- iOS_Json字符串转字典、字典转成Json字符串
- iOS开发-字典转字符串
- iOS 字典转JSON字符串
- C#Json字符串转字典
- c#中 实现 字符串转字典数据 字符串转字典 数组字典转字符串
- //普通字符串转JSON字符串转字典
- 给定一个源字符串,一个字符串字典,判断该字典是否是由源字符串完全分割而来的
- Python Decorator
- linux下字符串函数总结
- Android自定义控件实战——滚动选择器PickerView
- PHP回调函数的实现方法
- 无法打开物理文件 "X.mdf"。操作系统错误 5:"5(拒绝访问。)"。 (Microsoft SQL Server,错误: 5120)解决
- 版本判断 字典转字符串
- iOS 时间类常用方法
- java 面向对象二
- 【IOS】浅拷贝和深拷贝
- Java类中的常用容器
- 蚁群算法Python实现
- Mysql数据库的索引原理
- 对5个数进行排序,需7次比较的方法
- mqtt 初识