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

Simple collision detection

I want to write a platform game, all I done before was puzzle games with no need of physics. All I need is simple collision detection, what I will supply the physics engine is position of all objects and it should output: All objects of a specific object type (bullets) that collide with any object […]

Why doesn't setValue:forKeyPath invoked on mutable dictionary throw exception for unknown keypaths?

I have following code: NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [defs setObject:[NSNumber numberWithInt:100] forKey:@”test1.test2.test3″]; [defs setValue:[NSNumber numberWithInt:10] forKeyPath:@”test2.test3.test4″]; I understand that setObject:forKey: creates association between “test1.test2.test3” key and given number object. On the other hand, setValue:forKeyPath: is Key-Value-Coding method that tries to locate object for path “test2.test3.test4”, but in the end, it just silently does nothing. […]

createFileAtPath & OCUnit & errno blues

I looked here and there but to no avail. Consider: – (void) write: (NSString *) xId data:(NSData *) data forClass: (Class) c { NSFileManager * fm = [NSFileManager defaultManager] ; NSString * instancePath = [self instancePath:xId forClass: c] ; errno = 0 ; BOOL success = [fm createFileAtPath: instancePath contents: data attributes: nil] ; if […]

AVAssetReader reads audio, then fails

My app reads audio and plays it back in a producer / consumer setup. The consumer thread requests new samples to render to hardware. The producer thread reads audio data from disk into its buffer using AVAssetReader. The producer thread runs in a loop, checking if more samples need to be read. The producer’s buffer […]

Odd compiler error when using Obj-C objects in a switch statement

I get a compiler error when using an Objective-C object within a switch statement: switch (myConstant) { case 0: UIViewController *myController = [[[UIViewController alloc] init] autorelease]; [self.navigationController pushViewController:myViewController animated:YES]; break; case 1: // stuff break; default: break; } The error states: Expected expression before ‘UIViewController’ ‘myViewController’ undeclared (first use in this function) I understand that […]

compare two NSDate fails

I try to compare two NSDate objects. But it fails all the time and I can not see what is wrong. -(IBAction)nextAction { NSDate *today = [NSDate date]; if([appStateDate compare:today] == NSOrderedAscending) { dispatch_async(calcQueue, ^{ [self plusOneDate]; }); } } Without the code it works fine. it just crashes, and EXE_BAD_ACCESS on this line in […]

creating event for IB

Is there a way to have a custom control send events that can be used from IB? Something like the events in UIButton’s “sent events” (such us touchUpInside)

Password field not visible on password protected pdf

I am using PDF kit framework to display/Edit pdf files. Its broken badly on macOS 10.12. Sometimes password protected files do not display password field and sometimes password field is visible in normal file.

GC Operation on unregistered thread

I am getting the following error on OS X Lion 10.7 in my application. I have pinpointed what is causing the error, but want to find out if this is a bug in 10.7 or if something has changed that I am missing. malloc: *** auto malloc[3677]: error: GC operation on unregistered thread. Thread registered […]

How to determine if a ViewController is top level or not?

I have a tab bar driven app. The app has some view controllers that are stacked on each other the usual way. Some of these view controllers may be top level – meaning instantiated directly from the tab bar controller. Those do not have a “back” button in their navigation bar. Some of these can […]