Objective C: How to upload image and text using HTTP POST?

Try this (EDITED): NSMutableData *body = [NSMutableData data]; // file [body appendData:[[NSString stringWithFormat:@”–%@\r\n”, boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@”Content-Disposition: attachment; name=\”userfile\”; filename=\”.jpg\”\r\n”] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@”Content-Type: application/octet-stream\r\n\r\n”] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[NSData dataWithData:imageData]]; [body appendData:[[NSString stringWithString:@”\r\n”] dataUsingEncoding:NSUTF8StringEncoding]]; // text parameter [body appendData:[[NSString stringWithFormat:@”–%@\r\n”, boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@”Content-Disposition: form-data; name=\”parameter1\”\r\n\r\n”] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[parameterValue1 dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@”\r\n”] dataUsingEncoding:NSUTF8StringEncoding]]; … Read more

How can I view the values inside an object in the Xcode debugger?

It’s frustrating. The debugger has to know the structure of every object and it apparently doesn’t. It used to be much worse, though. Like with NSArray’s, they’re an array of objects. The debugger doesn’t know what type of objects specifically, and that’s due to the Objective-C language, not the debugger. As you dive into iOS … Read more

How to disable cache on IOS safari?

I just stumbled across a way to disable cache in Safari on iOS: iOS Open Settings Navigate to Safari > Advanced Enable Web Inspector Switch back to Safari and load a web page Desktop Open Safari Navigate to Safari > Preferences > Advanced tab Enable the Develop menu In the Develop menu, select Your iOS … Read more

Prevent iOS from taking screen capture of app before going into background

You are on the right track. This is Apple’s recommended way to do this as noted in the iOS Application Programming Guide: Remove sensitive information from views before moving to the background. When an application transitions to the background, the system takes a snapshot of the application’s main window, which it then presents briefly when … Read more