Tag: networking

Cloudkit:CKDatabaseOperation不适用于手机

嗨,所有的CloudKit用户: 我有一个可怕的时间试图找出为什么CKDatabaseOperation不会给任何反馈。 没有错误,在蜂窝上保存CKRecords时没有callback。 你能不能让我知道你对此有何看法?

iPad上的图像大小限制?

我开发了一个networking应用程序,并注意到我的缩放function不适用于某些图片,并意识到一些图片实际上resize。 看看这些例子(在iPad2上testing): http://zoom-test.magent-server.de/bild1.html – >以gif格式显示的图片完整大小 http://zoom-test.magent-server.de/bild2.html – >原始大小相同的jpg格式图片,但在iPad上缩小 我无法弄清楚什么时候图片缩小了。 用gif显然不会发生,但也不总是与jpg。 它也不取决于图像大小或resoultion。 我testing的图像尺寸比例子中的尺寸要小,但是我找不到图案。 有什么办法可以防止图像尺寸缩小? 或者至less有一个定义,所以我知道哪些图片将减less,哪些不是。

AFNetworking在会话中存储login用户

使用AFNetworking,我可以成功login,没有任何问题,并存储会话。 只要我停止debugging在Xcode,模拟器仍然是开放的,但进入iPhone的主屏幕。 当我再次从xcode运行应用程序,login会话消失,用户为零,花了几个小时,不知道为什么。 我的问题是停止debugging与会议的login用户? 是否使用setAuthorizationHeaderWithUsername必须处理任何事情。 @property (retain, nonatomic) NSDictionary* user; login: [[API sharedInstance] commandWithParams:params onCompletion:^(NSDictionary *json) { //handle the response NSDictionary* res = [[json objectForKey:@"result"] objectAtIndex:0]; if ([json objectForKey:@"error"]==nil && [[res objectForKey:@"IdUser"] intValue]>0) { //success [[API sharedInstance] setUser:res]; } }]; API: +(API*)sharedInstance { static API *sharedInstance = nil; static dispatch_once_t oncePredicate; dispatch_once(&oncePredicate, ^{ sharedInstance = […]

didReceiveRemoteNotification:fetchCompletionHandler:下载冻结

我们的应用程序利用didReceiveRemoteNotification: fetchCompletionHandler:方法UIApplicationDelegate在收到content-available推送通知时开始下载。 应用程序采取的各个步骤: [1]接收通知 – (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler { NSLog(@"Remote download push notification received"); [AFHTTPSessionManager_Instance downloadFile:completionHandler]; } [2]开始一个新的下载任务 – (void)downloadFile:(void (^)(UIBackgroundFetchResult))completionHandler { NSURLSessionDownloadTask *task = [AFHTTPSessionManager_Instance downloadTaskWithRequest:request progress:nil destination:nil completionHandler:nil]; [task resume]; NSLog(@"Starting download of %@", request.URL.absoluteString); // Some additional time to start the download dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ […]

AFNetworking 2.0 setImageWithURLRequest

我在当前的项目中下载图片时使用了这段代码,并没有与AFNetworking 2.0一起工作。 我试图通过AFImageResponseSerializer,但我找不到合适的代码使用。 [cell.posterImage setImageWithURLRequest:urlRequest placeholderImage:[UIImage imageNamed:@"placeholder.png"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) { cell.posterImage.image = image; } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) { NSLog(@"Request failed with error: %@", error); }]; 关于AFNetworking 2.0中使用的新代码的任何build议? 谢谢!

AFNetworking HTTP POST上传图像在接近完成时停止

我正在使用下面的代码HTTP POST一个多部分的Web表单,包括一个JPEG图像。 码: NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [params setObject:nameField.text forKey:@"name"]; [params setObject:emailField.text forKey:@"email"]; [params setObject:titleField.text forKey:@"title"]; [params setObject:dateString forKey:@"link"]; [params setObject:descriptionTV.text forKey:@"content"]; [params setObject:tag forKey:@"tags"]; NSData* sendData = UIImageJPEGRepresentation(uploadedPhoto.image, 1.0); AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://example.com/"]]; NSMutableURLRequest *afRequest = [httpClient multipartFormRequestWithMethod:@"POST" path:@"form" parameters:params constructingBodyWithBlock:^(id <AFMultipartFormData>formData) { [formData appendPartWithFileData:sendData name:@"image" fileName:@"image.jpeg" mimeType:@"image/jpeg"]; }]; […]

上传使用AFNetworking

NSURL *url = [NSURL URLWithString:@"http://127.0.0.1:8000/photo/"]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; NSDictionary *headers = [NSDictionary dictionaryWithObject:data forKey:@"attachment"]; //NSLog(@"strimng"); NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"upload/" parameters:nil constructingBodyWithBlock: ^(id<AFMultipartFormData> formData) { NSLog(@"strimng"); [formData appendPartWithFileData:data name:@"attachment" fileName:@"attachment.jpg" mimeType:@"image/jpeg"]; NSLog(@"strimng"); }]; NSLog(@"strimng"); AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { NSLog(@"Sent […]

使用AFNetworking下载文件时的内存警告

更新: 我写了一个非常简单的下载代码: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSURLRequest* request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://xxxx.s3.amazonaws.com/products/ipad/xxxx.mp4"]]; for(int i=0; i<4; i++){ NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,[NSString stringWithFormat:@"xxxx%d.mp4",i]]; AFDownloadRequestOperation* operation = [[AFDownloadRequestOperation alloc] initWithRequest:request targetPath:filePath shouldResume:YES]; operation.outputStream = [NSOutputStream outputStreamToFileAtPath:filePath append:NO]; [operation setShouldOverwrite:YES]; [operation setProgressiveDownloadProgressBlock:^(AFDownloadRequestOperation *operation, NSInteger bytesRead, long long totalBytesRead, long […]

Restkit授权标题消失

我已经到处搜寻,这个应该是微不足道的问题比我想要的要花的时间还要长,因此我正在向你寻求帮助。 我正在使用cocoapods使用快速和集成的restkit。 尽pipe你可以看到截图/日志,但是头部没问题,但是传出的http数据包并不一致。 AppDelegate中: RKlcl_configure_by_name("RestKit/Network", RKlcl_vTrace.value); RKlcl_configure_by_name("RestKit/ObjectMapping", RKlcl_vTrace.value); ObjectManagerCode: let objectManager: RKObjectManager = RKObjectManager(baseURL: NSURL(string: Endpoints.BaseUrl.toString())) objectManager.requestSerializationMIMEType = RKMIMETypeJSON; let username = "TestUser" let password = "password" objectManager.HTTPClient.setAuthorizationHeaderWithUsername(username, password: password) objectManager.HTTPClient.setDefaultHeader("whatIWantForChristmas", value: "You") objectManager.HTTPClient.allowsInvalidSSLCertificate = true 请求: var requestUrl = cds.objectManager!.requestWithObject( nil, method: RKRequestMethod.GET, path: endpoint.path, parameters: endpoint.parameters()) cds.objectManager!.getObjectsAtPath( endpoint.path, parameters: endpoint.parameters(), success: { (RKObjectRequestOperation, […]

我怎样才能在AFNetworking 3.0迁移?

我正在迁移AFNetworking 3.0。 我在AFNetworking中使用AFHTTPRequestOperation,但在最近的更新中删除了它。 我尝试了所有可能的解决scheme。 基本上我需要发布一个JSON头。 我将我的NSDIctionary转换成JSON对象,然后将其添加为string。 这里是我的Header的示例JSON RequestHeader={ "lname" : "sadhsdf", "bday" : "2003-03-13", "age" : "12", "address" : "dsfhskdjgds", "gender" : "M", "cnumber" : "12312412", "fname" : "sadhsdf", "RequestType" : "userregistration", "Email" : "sldjlkasd@sjdhflksdf.com", "status" : "dsfhskdjgds", "Password" : "123456" } RequestHeader是一个NSString,其余的都是NSDictionary。 我如何将它应用于AFNetworking 3.0? 先谢谢你。