RSS
 

Posts Tagged ‘iphone’

How to call a Block after a delay

Posted on Wednesday, February 22, 2012
22 Feb

On iOS and on OS X you sometimes need the User Interface to update after a short delay. The old way of doing it was calling the performSelector:withObject:afterDelay: selector on any NSObject subclass but that requires defining a new method in your class and you can only pass one object as a parameter.

Instead, you can use dispatch_after from the Grand Central Dispatch APIs to execute code within a block after a certain time interval. Don’t be afraid, it might be low-level C but you can cut and paste and just put your code inside and it will retain the variable scope that blocks usually do!

double delayInSeconds = 0.5;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
 
  // Your code here
 
});
 
 

Core Animation stops animation on app relaunch

Posted on Monday, September 19, 2011
19 Sep

On one of my projects I discovered a bug in a never-ending animation I had set up. Whenever the app was suspended (such as when you multitask and open another app), on relaunching the app the animation was frozen. After some investigating, I discovered that you need to set a flag on the CABasicAnimation called removedOnCompletion to NO otherwise the animation will get cleaned up when it gets suspended.

CABasicAnimation *dartWiggleAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
dartWiggleAnimation.fromValue =
   [NSValue valueWithCGPoint:CGPointMake(self.center.x-DART_WIGGLE_HALF, self.center.y+DART_CENTER_H_OFFSET)];
dartWiggleAnimation.toValue =
   [NSValue valueWithCGPoint:CGPointMake(self.center.x+DART_WIGGLE_HALF, self.center.y+DART_CENTER_H_OFFSET)];
dartWiggleAnimation.timingFunction =
   [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut]; 
 
dartWiggleAnimation.duration = 0.4;
dartWiggleAnimation.repeatCount = HUGE_VALF;
dartWiggleAnimation.autoreverses = YES;
dartWiggleAnimation.removedOnCompletion = NO;
 
[[nextDart layer] addAnimation:dartWiggleAnimation forKey:@"dartWiggle"];

Does this seem like a bug or a feature?

 

Reverting your library from a beta of iTunes

Posted on Wednesday, September 14, 2011
14 Sep

As an iPhone and iPad developer, Apple often present you with beta versions to install which sometimes require you to also install a beta version of iTunes. Of course the contents of these beta versions are under strict non-disclosure agreements but the process of rolling back isn’t so I’ll quickly explain how to do it…

When you installed the beta, it will upgrade your iTunes library database but if you try to downgrade back to the old version at a later date you’ll be presented with an error message saying that iTunes cannot read your library.

Don’t panic! The beta version has just moved your library database to a backup folder and with a simple drag and drop you can have your old library database up and running again. Your old database should be found in ~/Music/iTunes/Previous iTunes Libraries dated with when you upgraded. Just drag that back into ~/Music/iTunes renaming it to iTunes Library.itl (you’ll probably need to delete the existing iTunes Library.itl file too as that belonged to the beta version and you just uninstalled that).

That’s all you need to do to get your old iTunes library working again. Just before you begin make sure you back up everything!

 
2 Comments

Posted in Apps, Mac OS X

 

WWDC Update: 5 key points for iPhone apps

Posted on Tuesday, July 5, 2011
05 Jul

It’s now been just over 3 weeks since the torrent of information unleashed at Apple’s World Wide Developer Conference refreshingly drenched the brains of designers, developers and engineers. I’ve resisted blogging about the public announcements to fully let the impact soak in and gage everyone’s reactions but now feels like a good time to talk about where the future of computing is heading.
Read the rest of this entry »

 

Pub Darts now with Facebook Support

Posted on Monday, November 15, 2010
15 Nov

Richard Warrender's photo in Pub DartsHey, just to let you know Pub Darts 1.2 is now up in the App Store.

The biggest feature this new version supports is Facebook integration. Yes thats right… you can now log in and pull a “friend’s” profile picture straight onto the dartboard ready to let off some steam. Mmm, now if only you could download and try it out for free… wait you can because I made it free for a short while!
Here’s the link for Pub Darts.

So what else is in this free update?
Well I’ll tell you. This is what some people have been begging me for…

  • Ability to refresh dartboard
    (You can now remove the tiny dart holes)
  • Dart sound effects
    (Satisfying thuds as a dart hits the board – woop!)
  • Bug fixes related to using camera and albums
    (Needed fixing particularly for large images)

Just in case you can’t find it, to access Facebook navigate to…
Settings > Boss Image > Camera > Grab From Facebook

Let me know what you’d like to see in the next update. Either in the comments or an email. Of course, you could always leave a really positive review if you enjoy it :D

 
2 Comments

Posted in Apps, Games, iPhone