Recent Comments

There are a total of 552 comments on this site.
Below are the most recent 30 of them, newest at the top.

Jay Versluis on How to fix "Couldn't communicate with a helper application" in Xcode 7

Saturday, 22nd April 2017

Excellent, thank you for sharing!

Adolfo Frias on How to fix "Couldn't communicate with a helper application" in Xcode 7

Tuesday, 18th April 2017

Worked for the latest update to Xcode 8.3.1! Thanks

Nive on How to fix "Couldn't communicate with a helper application" in Xcode 7

Monday, 6th March 2017

Thanks works for me!!

Stev on How to fix "Couldn't communicate with a helper application" in Xcode 7

Friday, 3rd March 2017

Jeesh, thanks. Never deny anything to an Apple app...

sagarsneh on How to fix "Couldn't communicate with a helper application" in Xcode 7

Sunday, 12th February 2017

Thanks!

Jay Versluis on How to use UIPasteboard to share data with iOS

Sunday, 5th February 2017

Excellent, thanks for sharing!

Paul on How to use UIPasteboard to share data with iOS

Sunday, 5th February 2017

Ah, I got it to work! I was using NSData but then found I did not need to do that as can use .image directly :-) THANKS ;-)

  //var myData = NSData()
        
  //self.textDocumentProxy.insertText(String(myData.length))
        
 // myData = NSData(data: UIImagePNGRepresentation(UIImage(named: "mymoji")!)!)
        
//UIPasteboard.general.setData(myData as Data, forPasteboardType:"com.mycom.mymoji")
        
UIPasteboard.general.image = UIImage(named: "mymoji")
        
self.textDocumentProxy.insertText(String(myData.length))
        
if (UIPasteboard.general.hasImages) {
            
    self.textDocumentProxy.insertText("Image in pasteboard");
            
 }
 else {
            
  self.textDocumentProxy.insertText("no image");
 }

Jay Versluis on How to use UIPasteboard to share data with iOS

Saturday, 4th February 2017

I would imagine UIPasteboard doesn't mind custom keyboards. How are you setting the image? Can you retrieve it without checking hasImages?

Paul on How to use UIPasteboard to share data with iOS

Saturday, 4th February 2017

Should this work on custom keyboards? I cannot get an image into general pasteboard, hasimages always returns false?

Jay Versluis on How to load different Storyboards for different versions of iOS in Xcode 5

Sunday, 29th January 2017

Glad you got it working :-)

John on How to load different Storyboards for different versions of iOS in Xcode 5

Saturday, 28th January 2017

So using your method, I edited to show the Start Controller to allow the user to show the options, if they do not set them, at all... just a simple else if added... code below for reference...

UIStoryboard *storyboard = nil;
        NSUserDefaults *defaultimperial = [NSUserDefaults standardUserDefaults];
        NSUserDefaults *defaultmetric = [NSUserDefaults standardUserDefaults];
        
        if ([defaultimperial boolForKey:@"unitSwitchImperial"])
        {
            // load imperial storyboard
            storyboard = [self grabStoryboardImperial];
        }
        else if ([defaultmetric boolForKey:@"unitSwitchMetric"])
        {
            // load metric storyboard
            storyboard = [self grabStoryboardMetric];
        }
         else
        {
            // load start storyboard
            storyboard = [self grabStoryboardStart];
        }
        // show the storyboard
        self.window.rootViewController = [storyboard instantiateInitialViewController];
        [self.window makeKeyAndVisible];
Then added the extra storyboard like this...
- (UIStoryboard*)grabStoryboardMetric {
    
    return [UIStoryboard storyboardWithName:@"iPhoneMetric" bundle:nil];
}

- (UIStoryboard*)grabStoryboardImperial {
    
    return [UIStoryboard storyboardWithName:@"iPhoneImperial" bundle:nil];
}

- (UIStoryboard*)grabStoryboardStart {
    
    return [UIStoryboard storyboardWithName:@"start" bundle:nil];
}
Again, thanks for all your help!

John on How to load different Storyboards for different versions of iOS in Xcode 5

Saturday, 28th January 2017

Your method is much more elegant than mine... Thanks for all your effort... it works!

John on How to load different Storyboards for different versions of iOS in Xcode 5

Saturday, 28th January 2017

If anyone is interested... I solved this using the following code...

if([defaultimperial boolForKey:@"unitSwitchImperial"])
        {
            /* Executes when the boolean expression is true */
            UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPhoneImperial" bundle:[NSBundle mainBundle]];
            UIViewController *vc =[storyboard instantiateInitialViewController];
            
            // Set root view controller and make windows visible
            self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
            self.window.rootViewController = vc;
            [self.window makeKeyAndVisible];
            NSLog(@"Imperial Storyboard");
        }
        
        else if([defaultmetric boolForKey:@"unitSwitchMetric"])
        {
            /* Executes when the boolean expression is true */
            UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPhoneMetric" bundle:[NSBundle mainBundle]];
            UIViewController *vc =[storyboard instantiateInitialViewController];
            
            // Set root view controller and make windows visible
            self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
            self.window.rootViewController = vc;
            [self.window makeKeyAndVisible];
            NSLog(@"Metric Storyboard");
        }
        
        else
        
        {
            /* executes when the none of the above condition is true */
            UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"start" bundle:[NSBundle mainBundle]];
            UIViewController *vc =[storyboard instantiateInitialViewController];
            
            // Set root view controller and make windows visible
            self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
            self.window.rootViewController = vc;
            [self.window makeKeyAndVisible];
            NSLog(@"Start Storyboard");
            
        }

Jay Versluis on How to load different Storyboards for different versions of iOS in Xcode 5

Saturday, 28th January 2017

Hi John, your logic is sound and it's definitely possible. Your code is correct too as far as I can see, there's just one small thing when it comes to checking the user defaults. In applicationDidFinishLaunching, you're saying "if the BOOL isn't set, then set it". This overrides the value every time the app starts, even if the user has chosen metric. What you want to do instead, "if the BOOL is set, load the imperial storyboard. And if the BOOL is not set, then load the metric storyboard". In code this could look something like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIStoryboard *storyboard = nil;
    NSUserDefaults *defaultimperial = [NSUserDefaults standardUserDefaults];
    
    if ([defaultimperial boolForKey:@"unitSwitchImperial"]) {
        // load imperial storyboard
        storyboard = [self grabStoryboardImperial];
        
    } else {
        // load metric storyboard
        storyboard = [self grabStoryboardMetric];
    }
    
    // show the storyboard
    self.window.rootViewController = [storyboard instantiateInitialViewController];
    [self.window makeKeyAndVisible];
    
    return YES;
}
Here's a quick demo project: https://github.com/versluis/Pick-a-Storyboard/ Hope this helps!

John on How to load different Storyboards for different versions of iOS in Xcode 5

Saturday, 28th January 2017

Wondering if this same code can be edited to allow the user to save the settings (preference) of which storyboard they prefer. I have an app that uses an Imperial Storyboard and a Metric Storyboard. At startup the user actually sees a Startup Storyboard and then they select Imperial or Metric... That works fine... I have an option to allow them to save their default unit of measure, so they don't have to select Imperial or Metric every time they start the app again using NSUserDefaults... Those defaults too save properly. My problem is, that I cannot tell in the AppDelegate file that if the user saved Imperial, how to only display the Imperial Storyboard on next entry, and of course, if the user selected Metric, how to load only that Storyboard. So while I came close to editing your sample (thank you) I am having a bit of trouble having the AppDelegate file handle the selection. If you have any advice much appreciated... Here is some sample code... (not working) no errors, just not selecting the saved Storyboard from the user preferences as every time the app starts up, it always goes to the Start Storyboard and not the Imperial or Metric Storyboard... ***Code Below *** in AppDelegate.m

- (UIStoryboard *)grabStoryboard {
    
    UIStoryboard *storyboard;
    
    // detect the user default preference unit of measure
    
    NSUserDefaults *defaultimperial = [NSUserDefaults standardUserDefaults];
    if (![defaultimperial objectForKey:@"unitSwitchImperial"]) {
        [defaultimperial setBool:YES forKey:@"unitSwitchImperial"];
        storyboard = [UIStoryboard storyboardWithName:@"iPhoneImperial" bundle:nil];
        
         NSLog(@"Imperial Measurement Storyboard");
    } else {
        
        NSUserDefaults *defaultmetric = [NSUserDefaults standardUserDefaults];
        if (![defaultmetric objectForKey:@"unitSwitchMetric"]) {
            [defaultmetric setBool:YES forKey:@"unitSwitchMetric"];
        }
        storyboard = [UIStoryboard storyboardWithName:@"start" bundle:nil];
         NSLog(@"Start Storyboard");
    }
    
    return storyboard;
}
Then in the following...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

NSUserDefaults *defaultimperial = [NSUserDefaults standardUserDefaults];
        if (![defaultimperial objectForKey:@"unitSwitchImperial"]) {
            [defaultimperial setBool:YES forKey:@"unitSwitchImperial"];
            
        }

UIStoryboard *storyboard = [self grabStoryboard];

       // show the storyboard
        self.window.rootViewController = [storyboard instantiateInitialViewController];
        [self.window makeKeyAndVisible];

*** so again, there are no errors, only that the app ALWAYS starts at the Start Storyboard, even though the user as selected the Imperial storyboard to start at the next time they enter the app... Any help much appreciated... John

Lyn on How to build a UICollectionView in iOS 8

Friday, 27th January 2017

Thank you so much for this tutorial. That one line of code was tripping me up for so long and now I can finally see my collection! Thanks again!

charlesr1971 on How to kill your app when it enters background mode

Monday, 16th January 2017

Excellent. Thanks Jay!

Jay Versluis on How to kill your app when it enters background mode

Monday, 16th January 2017

You're absolutely right, and you're in luck too, because Apple have half-implemented something like that. Here's what you can do:

  • plugin your device into your Mac (only works with real devices, not the simulator)
  • open Xcode
  • navigate to Window - Devices, then select your device
Xcode will now read the device's log file and display it (remember the log file contains every message any system service or app wants to write in there, including our own NSLog messages). As you use your device, you can see new messages displayed in real time.

charlesr1971 on How to kill your app when it enters background mode

Monday, 16th January 2017

Jay. That's a great explanation, but "where there is a will, there is a way..." Apple should be able to build this functionality into XCode, maybe as a preference.

Jay Versluis on How to kill your app when it enters background mode

Monday, 16th January 2017

Hi Charles, I guess that's expected behaviour. Terminating the app from within the app is like stopping it in Xcode, which means the connection between Xcode and the running app is broken. When you relaunch the app from the device, Xcode does not know about it and hence there's no communication between the device and Xcode. The log output is still written to the device though, it's just not displayed dynamically in Xcode.

Charles Robertson on How to kill your app when it enters background mode

Monday, 16th January 2017

Great tip Jay, but here is a more difficult issue that you may be able to resolve. How do I restore NSLog to console after applicationWillTerminate is called in the simulator. Try it and you will see that NSLog stops displaying to console in XCode, once you have terminated the app & relaunched. Any ideas?

haik on How to use Swift classes in Objective-C

Saturday, 31st December 2016

Awesome, thanks a lot !

Cristian on Xcode crashes every time you open it – and how to fix it

Friday, 16th December 2016

Thaks! it's works for me!

Nikita Sahu on Xcode crashes every time you open it – and how to fix it

Thursday, 15th December 2016

Thanks man you saved me.

Jason Harrison on Xcode crashes every time you open it – and how to fix it

Tuesday, 29th November 2016

THANK YOU

Jay Versluis on How to play videos in iOS 9

Wednesday, 23rd November 2016

I know it's been a while, but I've finally found a way on how to react to the end of the video. It's a notification we can make use of, called name: AVPlayerItemDidPlayToEndTimeNotification.

// register notificaton for end of movie
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(repeatVideo:) name:AVPlayerItemDidPlayToEndTimeNotification object:self.playerView.player.currentItem];
Once registered, add a method and do whatever you like, for example start playing the same video again:
- (void)repeatVideo:(NSNotification *)notification {
    
    // react by setting the video back to 0

    [self.playerView.player seekToTime:kCMTimeZero];
    
    // then play it again
    [self.playerView.player play];
}
Or do anything else you need, for example make your view small again. The notification does contain the player object. We can even do the whole thing as a (totally unreadable) block, in which code can be defined in the notification registration. For completion:
// register notification using a block

[[NSNotificationCenter defaultCenter]addObserverForName:AVPlayerItemDidPlayToEndTimeNotification object:self.playerView.player queue:nil usingBlock:^(NSNotification * _Nonnull note) {
    
    // your "end of video" code goes here
    [self.playerView.player seekToTime:kCMTimeZero];
    [self.playerView.player play];
}];
Hope this helps!

Rp on How to control the Preview Screenshot in the iOS Multitasking Switcher

Wednesday, 16th November 2016

Is this working on iOS 10.1.1 ? I downloaded the git project and tried to run on iPhone 6plus with iOS 10.1.1. I start the app and do the app switching and I see the content.

bharathreddys on How to fix "Couldn't communicate with a helper application" in Xcode 7

Tuesday, 8th November 2016

Super.... Works with Xcode 8 as well...

Jay Versluis on Creating an In-App Purchase in iOS 7 and Xcode 5.1

Monday, 7th November 2016

Hi Devan, I've just checked your code in my demo app (at the bottom of the article), and I'm not getting the problem. The only thing I've changed is the count variable (NSUInteger instead of int, because Xcode was throwing a warning there). Perhaps something is wrong with your product identifier?

SKProduct *validProduct = nil;
    NSUInteger count = response.products.count;
    if(count > 0){
        validProduct = [response.products objectAtIndex:0];
        NSLog(@"Products Available!");
        // works for me
    }
    else if(!validProduct){
        NSLog(@"No products available");
        // not called when there's at least one valid product
There's also a written article about how to do this here, perhaps it helps: http://pinkstone.co.uk/how-to-create-a-single-in-app-purchase-in-ios-7/

devanrajuios on Creating an In-App Purchase in iOS 7 and Xcode 5.1

Monday, 7th November 2016

Hi jay, A very good tutorial, but i can't able to get the product from the iTunes connect. didReceiveResponse delegate method is calling but the response is i don't have the products. - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{ SKProduct *validProduct = nil; int count = [response.products count]; if(count > 0){ validProduct = [response.products objectAtIndex:0]; NSLog(@"Products Available!"); [self purchase:validProduct]; } else if(!validProduct){ NSLog(@"No products available"); //this is called if your product id is not valid, this shouldn't be called unless that happens. } } Can u please suggest me what are the possible errors Thanks in Advance Devan Raju