现在我有xcode 6.0(Beta)作为我的xcode的默认版本.
今天我从app store安装了xcode 6,但我想将xcode 6设置为默认版本.
我怎么设置它?
提前致谢.
我使用AFNetworking库使用POST方法在服务器上发布数据.
以下是我的代码
- (void) callLoginAPI:(NSDictionary *)dictProfile{
// 1
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:[dictProfile valueForKey:@"name"], @"username",
[dictProfile valueForKey:@"first_name"],@"first_name",
[dictProfile valueForKey:@"last_name"],@"last_name",
[dictProfile valueForKey:@"email"],@"email",
[dictProfile valueForKey:@"birthday"],@"dob",
[dictProfile valueForKey:@"gender"],@"gender",
[[dictProfile valueForKey:@"location"] valueForKey:@"name"],@"location",
[dictProfile valueForKey:@"timezone"],@"timezone",
@"",@"language",
[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?type=large",[dictProfile valueForKey:@"id"]],@"profile_pic_url",
@"",@"cover_pic_url",nil];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager POST:@"http://10.1.81.35:8000/api/login/" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
Run Code Online (Sandbox Code Playgroud)
但我得到了以下错误的回应
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用afnetworking.
要在服务器上发布数据,我写了以下代码
- (void) callLoginAPI:(NSDictionary *)dictProfile{
// 1
NSDictionary *params = @{@"username":[dictProfile valueForKey:@"name"],
@"first_name":[dictProfile valueForKey:@"first_name"],
@"last_name":[dictProfile valueForKey:@"last_name"],
@"email":[dictProfile valueForKey:@"email"],
@"dob":[dictProfile valueForKey:@"birthday"],
@"gender":[dictProfile valueForKey:@"gender"],
@"location":[[dictProfile valueForKey:@"location"] valueForKey:@"name"],
@"timezone":[dictProfile valueForKey:@"timezone"],
@"language":@"",
@"profile_pic_url":[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?type=large",[dictProfile valueForKey:@"id"]],
@"cover_pic_url":@""
};
NSString* HOST_URL = [NSString stringWithFormat:@"%@login/",BASE_URL];
AFHTTPRequestOperationManager *operationManager = [AFHTTPRequestOperationManager manager];
operationManager.requestSerializer = [AFJSONRequestSerializer serializer];
[operationManager POST:HOST_URL parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject){
NSLog(@"resp:%@",responseObject);
// Enter what happens here if successsful.
}failure:^(AFHTTPRequestOperation *operation, NSError *error){
NSLog(@"error:%@",error);
// Enter what happens here if failure happens
}];
}
Run Code Online (Sandbox Code Playgroud)
但作为回应我得到了以下错误
error:Error …Run Code Online (Sandbox Code Playgroud) 我正在使用AFnetworking库在服务器上发布数据.
以下是我在服务器上发布数据的代码.
- (void) callLoginAPI:(NSDictionary *)dictProfile{
// 1
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:[dictProfile valueForKey:@"name"], @"username",
[dictProfile valueForKey:@"first_name"],@"first_name",
[dictProfile valueForKey:@"last_name"],@"last_name",
[dictProfile valueForKey:@"email"],@"email",
[dictProfile valueForKey:@"birthday"],@"dob",
[dictProfile valueForKey:@"gender"],@"gender",
[[dictProfile valueForKey:@"location"] valueForKey:@"name"],@"location",
[dictProfile valueForKey:@"timezone"],@"timezone",
@"",@"language",
[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?type=large",[dictProfile valueForKey:@"id"]],@"profile_pic_url",
@"",@"cover_pic_url",nil];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager POST:@"http://10.1.81.35:8000/api/login/" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
Run Code Online (Sandbox Code Playgroud)
并作为回应我得到以下错误
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)" UserInfo=0x7c87b6f0 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7cc220e0> { URL: …Run Code Online (Sandbox Code Playgroud) 我有一个字符串如下:
NSString *str = @"abcd,efgh";
Run Code Online (Sandbox Code Playgroud)
现在我想将此字符串转换为NSMutableArray之类的
NSMutableArray *arr = {abcd,efgh};
Run Code Online (Sandbox Code Playgroud)
那怎么办呢?
任何帮助,将不胜感激.
我已经编写了在instagram上传图像的代码,如下所示:
CGRect rect = CGRectMake(20 ,20 , 200, 200);
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndImageContext();
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *jpgPath = [documentsDirectory stringByAppendingPathComponent:@"after2sm.ig"];
NSString *fileURL = [NSString stringWithFormat:@"file://%@",jpgPath];
NSURL *igImageHookFile = [NSURL fileURLWithPath:fileURL];
self.dic.UTI = @"com.instagram.photo";
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
[NSDictionary dictionaryWithObject:@"My Caption" forKey:@"InstagramCaption"];
[self.dic presentOpenInMenuFromRect:rect inView:self.view animated:YES];
Run Code Online (Sandbox Code Playgroud)
但是它会打开一个带有"instagram"选项的动作表,但是当我点击它没有任何反应时,请你帮助我
iphone ×5
afnetworking ×3
objective-c ×3
ios ×2
json ×2
instagram ×1
ios6 ×1
nsstring ×1
uidocument ×1
xcode ×1