cocoa-touch

Use a button to change the orientation of the iPhone

Is there a way to change the orientation of the iPhone using a button? ...

iPhone "slide to unlock" animation

Any ideas as to how Apple implemented the "slide to unlock" (also, "slide to power off" is another identical example) animation? I thought about some sort of animating mask - but masking is not available on the iPhone OS for performance reasons. Is there some private API effect (like SuckEffect) that they might have used? A spotlight t...

How do you pass data between views using a UINavigationController

I have tried using the obvious method as outlined in the following example but my passed variable (rootcategory) is still nil on viewDidLoad in the loaded view http://www.iphonesdkarticles.com/2008/08/table-view-tutorial-part-3.html This is my code: CategoryViewController *viewController = [[CategoryViewController alloc] initWithNibNa...

What is the iPhone SDK Missing?

I've been doing mobile app development for a long time (2001?), but the systems we worked with back then were dedicated mobile development environments (Symbian, J2ME, BREW). iPhone SDK is a curious hybrid of Mac OS X and Apple's take on mobile (Cocoa Touch). But it is missing some stuff that other mobile systems have, IMO. Specifically...

Exist a generic library of validators for obj-c?

I wonder if already exist a generic library of validator suitable for a iPhone project (or better, bussines objects) for obj-c. Things like: Validator.IsNotEmpty.. Validator.IsValidEmail.. Validator.IsValidZipCode.. Validator.IsValidRegex.. Validator.IsInRange.. ...

Does UIActivityIndicator require manual threading on iPhone

I am running creating an iPhone application which performs a costly operation and I wanted to create an activityIndicator to let the user know the application has not frozen. The operation is performed entirely in one event call... so there is no chance for the UI framework to receive control to actually display and animate this indicat...

I am having trouble making connections between code and Interface Builder

I am having a peculiar problem with the iPhone SDK. I have tried to run several tutorials from different sources on my development machine. The problem always seems to be in connecting the code to a view in Interface Builder. If I have a button or data field (or some other library function) and I declare some properties in the viewcon...

Core Animation with a Core Graphics drawing

I am inside a UIView subclass (CustomView in the code below). I am drawing a border around an image in a UIImageView subclass (containerView). The Core Graphics code for this is located inside drawInRect: in the subclass. The Core Animation transition is a flip, however when it is drawn, the Core Graphics code is not used, i.e. drawIn...

Hiding the Keyboard

I have a UISearchBar and on the delegate method I hide the keyboard when the text field is cleared: - (void)searchBar:(UISearchBar *)filterBar textDidChange:(NSString *)filterText { NSLog(@"filter: %@", filterText); if ([filterText length] == 0) { NSLog(@"hiding keyboard"); [filterBar resignFirstResponder ]; N...

Formatting text in NSTextView

I have a case where i'm getting formatted text with <a href ...>, <em>, <br>, &quot;, etc tags, and i'm showing it in a Text View. How can i apply these formats? If i can't, whats the most generic way to remove all these tags? Thanks, Mustafa ...

Techniques for implementing -hash on mutable Cocoa objects

The documentation for -hash says it must not change while a mutable object is stored in a collection, and similarly the documentation for -isEqual: says the -hash value must be the same for equal objects. Given this, does anybody have any suggestions for the best way to implement -hash such that it meets both these conditions and yet is...

How do you create hybrid XCode projects for Mac & iPhone?

Hello, I'm working on a project which shall contain two targets. One for building a Framework to use in Mac development and another to create a static library to use in iPhone development. In the common code it's no problem to #ifdef between the platforms, but I just can't get the targets and dependencies right. The first question is, ...

What could affect the lifespan of a NSString returned by stringWithContentsOfFile"?

Consider the 2 following methods of reading a string from a file: NSString *path = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"txt"]; NSString *string = [NSString stringWithContentsOfFile:path encoding:NSASCIIStringEncoding error:NULL]; NSString *path = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"txt"]; NSFileH...

Store a number in an integer string and recall it in a later action

I'm currently trying to get a UISlider to work. I'm trying to set the strings value as 8 to start off with on view load. Then when the slider changes value I want the string to update with that number, and then later on I can use the value in the string for a setDuration:## later on in another action. Any ideas? ...

How do I remove illegal characters from an NSString?

I am parsing a tab seperated list using a NSScanner based upon each line and the tabs. However for some reason the last field in the array (parsed from each row) contains a \r character. How can I strip this from the NSString that represents the line (or the field) ...

Adjust UILabel height depending on the text

Consider i have the following text in a UILabel (a long line of dynamic text): Since the alien army vastly outnumbers the team, players must use the post-apocalyptic world to their advantage, such as seeking cover behind dumpsters, pillars, cars, rubble, and other objects. I want to resize the UILabel's height so that the text can...

Triggering a method to run in a separate thread

I want to know how I can run a method in a separate thread? Class & Method references. Thanks. ...

How to get pixel data from a UIImage (Cocoa Touch) or CGImage (Core Graphics)?

I have a UIImage (Cocoa Touch). From that, I'm happy to get a CGImage or anything else you'd like that's available. I'd like to write this function: - (int)getRGBAFromImage:(UIImage *)image atX:(int)xx andY:(int)yy { // [...] // What do I want to read about to help // me fill in this bit, here? // [...] int result = (red << 2...

How do I reset after a UIScrollView zoom?

I have a Graph being drawn inside a UIScrollView. It's one large UIView using a custom subclass of CATiledLayer as its layer. When I zoom in and out of the UIScrollView, I want the graph to resize dynamically like it does when I return the graph from viewForZoomingInScrollView. However, the Graph redraws itself at the new zoom level, ...

SQLite: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error: failed to open database with message 'not an error'.'

I am making an app with many database operations. Since SQLite caches data, in my applicationDidReceiveMemoryWarning method, I am closing the database and opening it again to delete the cached data. When the do this, I get this error *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error: failed...