小编ass*_*fey的帖子

将日期从时区转换为设备本地时区和日期

如何将timezone1的日期转换为设备本地时区2的日期?

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
[dateFormat setTimeZone:[NSTimeZone timeZoneWithName:@"Asia/Jerusalem"]];
NSDate *date = [dateFormat dateFromString:timestamp];

then something like:
[dateFormat2 setTimeZone:[NSTimeZone localTimeZone]];
date2 = [dateFormat2 dateFromDate:date withOtherTimeZone:zone];
Run Code Online (Sandbox Code Playgroud)

更新:

我想我明白了.

//get source date from the server
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
NSDate *sourceDate = [dateFormat dateFromString:timestamp];

//set timezones
NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithName:@"Asia/Jerusalem"];
NSTimeZone* destinationTimeZone = [NSTimeZone systemTimeZone];

//calc time difference
NSInteger sourceGMTOffset = [sourceTimeZone secondsFromGMTForDate:sourceDate];
NSInteger destinationGMTOffset = [destinationTimeZone secondsFromGMTForDate:sourceDate];
NSTimeInterval interval = destinationGMTOffset …
Run Code Online (Sandbox Code Playgroud)

timezone nsdate nsdateformatter ios

2
推荐指数
1
解决办法
6611
查看次数

以最快的方式获取Facebook好友个人资料图片 - iOS

我正在尝试使用FBConnect获取我的朋友照片,请求的URL是:

pictureURL =  [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?width=50&height=50", [data objectForKey:@"id"]];
Run Code Online (Sandbox Code Playgroud)

图像设置在这里:

NSString *pictureUrl = [[NSString alloc] initWithFormat:@"%@", [self getProfileUrl:object]];
[friend setImage:pictureUrl];
Run Code Online (Sandbox Code Playgroud)

set方法是:

NSData *pictureData = [NSData dataWithContentsOfURL:[NSURL URLWithString:pictureUrl]];
UIImage *image = [UIImage imageWithData:pictureData];
if (image != nil)
    friendImage = image;
Run Code Online (Sandbox Code Playgroud)

非常简单,但是对于大量的朋友来说,这个过程需要太长时间,有没有办法让个人资料图像更快,或者更有效率呢?

iphone facebook objective-c facebook-graph-api ios

1
推荐指数
1
解决办法
3329
查看次数