cocoa-touch

Using Core Animation with objects other than CALayers

I was pretty sure I had seen discussions of this around the Net, but now I can't seem to find anything. The question is simple: is there a way to use for example CABasicAnimation to animate a property on an object that's not a ´CALayer´? (Say, the ´volume´ property on an ´AVAudioPlayer´.) If not, is there a way to make it work other tha...

How to reduce memory footprint when instantiating a hierarchy of model objects in Cocoa?

I'm writing a quiz application for iPhone using basic NSObject subclasses to represent the models. At runtime the various controllers instantiate the model classes and populate them with data read in from a plist on the disk. The model classes represent the basic hierarchy of a multiple choice quiz: One application has many quizzes O...

Best practice for ownership of a UINavigationController in a navigation based app?

Hi all My small app is growing more sprawling and I'm looking for some best practice advice on the management/ownership of view controllers and navigation controllers. Here's what I'm doing now: AppController is a singleton that creates and owns a UINavigationController instance. The app controller, and thus the navigation controller,...

How to convert an NSArray of NSManagedObjects to NSData

Hi, I'm new to Objective C and was wondering if anyone can help me. I am using core data with a sqlite database to hold simple profile objects which have a name and a score attribute (both of which are of type NSString). What I want to do is fetch the profiles and store them in an NSData object, please see my code below: ...

Is it possible to be notified when a UITableView finishes scrolling?

I referenced this question: http://stackoverflow.com/questions/993280/how-to-detect-when-a-uiscrollview-has-finished-scrolling UITablewView is a subclass of UIScrollView, and my UITableView delegate does get the - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView message when I scroll the table by hand. However, when I call...

Customize TableviewCell depending on section

Hi folks, How do I customize the background image of a tableViewCell depending on the section, they are in? E.g. in section one, the cells are supposed to have a green .png image as a background image, whereas in section two, the cells are supposed to have a red .png image as background. Thank you for your help! gstar ...

iPhone dev - Set position of a view in viewDidLoad

So, in Interface Builder I have a view within the superview that contains two Image View objects. I'd like to move that view off the screen when the app launches so it can be animated to move into place. The view is described as pictureFrame in the .h file for the interface, and I have the view mapped to the outlet pictureFrame. Here is ...

Need to filter certain UIWebView requests and load them in different UIWebViews.

Some Background I have an iPhone app with three UIWebViews, each used to show a different type of page. (The content is specifically designed for this purpose, they're not real web pages.) There are links associated with each specific web view. For example, a link tapped in WV1 might need to load in WV2 because it's a WV2-style link. (T...

Text input box like the SMS app on the iPhone

I am having a terrible time trying to get an input box like the one in the SMS app. Can anyone offer some guidance on how to build one of these and make it look good? I need an input box that is shaped nicely like the UITextfield but will stretch vertically when typing. I assume that I need to calculate width of the text and stretch ...

Utility Application and View-Based application

Hi everybody, I'm new to xcode and the iphone sdk. I've been working with the view-based application for quite a while, and I was wondering if a utility application and a view based application involved the same type of coding. Can someone point out the difference for me? Thanks ...

UITableview titleForHeaderInSection not displaying correctly

I have some VERY simple code to return the title for a section header: - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if (section==0) { return @""; } else if (section==1) { return @"Actions"; } else if (section==2) { return @"Attached To"; } retu...

UITableView Core Data reordering

I know this question has been asked before, and I took a look at the answer to this question. However, I'm still confused as to how to implement reordering with a UITableView in a Core Data project. What I know is that I need to have a "displayOrder" attribute in my Entity to track the order of items, and I need to enumerate through all ...

[iphone] Is there a class teardown counterpart to +initialize?

I'm sure it is wishful thinking, but is there a counterpart to +initialize that will automatically get called when all instances of a class have been dealloc'ed? I allocate a singleton object in +initialize, which is called before my first class instance gets alloc'ed. I would love to be able to release the object once my class insta...

Call a method by clicking a button in a UIWebView

Hello, I want to generate some HTML content and put this into a UIWebView. The HTML contains some buttons. Is it possible to define actions for these buttons? I want to call a method (e.g. firstButtonPressed) in my objective-c code when someone presses this button in the UIWebView. Thanks you for helping me. ...

When Should I Use The Interface Builder?

As I'm learning the iPhone API, the book I'm using has me doing everything possible with the Interface Builder. We (lonely here sometimes) are writing code, too, but I really feel like I'm getting to know the Interface Builder quite well. I know that the Interface Builder is different from other GUI Builders as it uses serialized object...

How do I scroll a set of UIScrollViews together?

Setup: I have a UITableView, each UITableViewCell has a UIScrollView. What I am trying to do is to get all of the UIScrollViews to scroll together, such that when you scroll one of them all of the UIScrollViews appear to scroll simultaneously. What I've done is subclass UITableView so that it has an array of all of the UIScrollViews wit...

How to get a UIViewController from a UIView via code

Guys, There is a way to get a view controller reference from a UIView object? I need something like this: MyParentViewController *myParentViewController = [self.view.superview controller]; Thanks in advance. ...

Inconsistent crash due to "message sent to deallocated instance" in iPhone App

Hi There, Originally, my application was crashing do to BAD_EXEC_ACCESS. I turned on NSZombieEnabled, that output is below. The crashing is extremely inconsistent, If it crashes, it always crashes in one of three places, but it doesn't always crash when passing over those lines of code. I.e. sometimes it crashes at one of those places w...

UIImageView subclass touch detection

I have a subclass of UIImageView that I need to know when is touched. (Full code below.) I have found and read both this and this. They were mildly useful, but neither really worked. Not only is my touchesBegan:withEvent: method not being called, the button behind the image is being pressed. Here is my code: Header file: @interface M...

iPhone: " 'class_name' may not respond to methd_name" and "Unrecognized selector" Errors

Hi, I have written an application in which I want to convert a .jpg image to .bmp format but I it fails with the error: class_name' may not respond to methd_name". My code is following : #import "CalculateRGBViewController.h" @implementation CalculateRGBViewController @synthesize skinImage; @synthesize lblRedColor,btn,img; str...