iOS Development is easy with XCode, Swift3, UITableView, cocatouch, let's build iPhone, iPad and Macbook Applications.

Is it possible to set a cookie manually using sharedHTTPCookieStorage for a UIWebView?

I have webviews inside of an iOS application that require an authentication cookie to be properly authenticated. I’m looking for a way to set a cookie inside of an iOS application’s webview without having to make an outbound request to set the cookie as I have auth information on the client already. This post shows […]

stringByAppendingPathComponent is unavailable

My app shares photo on Instagram, to do this it first saves it on a temporary directory: let writePath = NSTemporaryDirectory().stringByAppendingPathComponent(“instagram.igo”) It was working on Swift 1.2, but does not work on Swift 2.0. Given error message is: stringByAppendingPathComponent is unavailable: use URLByAppendingPathComponent on NSURL instead.

UIViewController viewDidLoad vs. viewWillAppear: What is the proper division of labor?

I have always been a bit unclear on the type of tasks that should be assigned to viewDidLoad vs. viewWillAppear: in a UIViewController subclass. e.g. I am doing an app where I have a UIViewController subclass hitting a server, getting data, feeding it to a view and then displaying that view. What are the pros […]

In absence of preprocessor macros, is there a way to define practical scheme specific flags at project level in Xcode project

Before swift I would define a set of schemes for alpha, beta, and distribution builds. Each of these schemes would have a set of macros that were defined to gate certain behaviors at the project level. The simplest example is the DEBUG=1 macro that is defined by default for all Xcode projects in the default […]

How to compress/resize image on iPhone OS SDK before uploading to a server?

I’m currently uploading an image to a server using Imgur on iOS with the following code: NSData* imageData = UIImagePNGRepresentation(image); NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* fullPathToFile = [[paths objectAtIndex:0] stringByAppendingPathComponent:@”SBTempImage.png”]; [imageData writeToFile:fullPathToFile atomically:NO]; [uploadRequest setFile:fullPathToFile forKey:@”image”]; The code works fine when run in the simulator and uploading a file from the simulator’s photo […]

Passing Data between View Controllers in Swift

I am trying to convert an app from Objective-C to Swift but I can’t find how to pass data between views using Swift. My Objective-C code is UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@”Main” bundle:nil]; AnsViewController *ansViewController; ansViewController = [storyBoard instantiateViewControllerWithIdentifier:@”ansView”]; ansViewController.num = theNum; [self presentViewController:ansViewController animated:YES completion:nil]; What that is doing is it basically takes the […]

iPhone : can we open pdf file using UIWebView?

Can we open the pdf file from UIWebView ? If any one has implemented this then please help me. Any code snippet or any weblink would help.

property not working with getter AND setter

I have defined a property… @property (nonatomic, strong) NSArray *eventTypes; I want to override the getter and setter… I have written this… – (void)setEventTypes:(NSArray *)eventTypes { _eventTypes = eventTypes; //do some stuff here. } This works fine but when I then add this… – (NSArray*)eventTypes { //do some stuff here. return _eventTypes; } Then both […]

CGContextDrawImage draws image upside down when passed UIImage.CGImage

Does anyone know why CGContextDrawImage would be drawing my image upside down? I am loading an image in from my application: UIImage *image = [UIImage imageNamed:@”testImage.png”]; And then simply asking core graphics to draw it to my context: CGContextDrawImage(context, CGRectMake(0, 0, 145, 15), image.CGImage); It renders in the right place, and dimensions, but the image […]

How to autoplay a YouTube video in a UIWebView

I have seen a lot of posts in here about this issue, but still couldn’t find a perfect answer for this problem. So I have a tableview, and each cell has a play button inside it. When the user tap the play button, I add a UIWebView to this cell, and play a YouTube video. […]