objective-c

What are the best Cocoa-Touch/iPhone programming blogs?

What are the best Cocoa-Touch/iPhone programming blogs? One blog per answer please. Some answers may overlap with Best Cocoa/Mac OS X programming blogs? , but I'm looking for blogs with good meaty iPhone specific content (i.e. code) ...

C: Pointers and Arrays Question

I keep reading that, in C, using pointer arithmetic is generally faster than subscripting for array access. Is this true even with modern (supposedly-optimizing) compilers? If so, is this still the case as I begin to move away from learning C into Objective-C and Cocoa on Macs? (As is the primary goal of my picking up C -- get enough th...

Which method name fits in best with Objective-C/Cocoa conventions?

Here's a quicky question. Which method name makes the most sense for an Objective-C Cocoa application? -(void) doSomethingWithAnimation:(BOOL)animated or: -(void) doSomething:(BOOL)animated or even: -(void) doSomethingAnimated:(BOOL)animated ...

Can an application find out information about currently playing song on iPhone/iPod Touch?

I've searched around a bit in the small amount of iPhone/iPod Touch development information available and couldn't find anything for or against. Can an application find out information about currently playing song on iPhone/iPod Touch? Since the music can continue to play while you are in 3rd party applications, is there a function or ...

Receive HTTP Headers via NSURLRequest/NSURLConnection in Cocoa

I've been working on figuring out how to receive HTTP Headers via a request made with NSURLConnection. Typically a request is made with something as simple as the following: NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; The only way I've personally found in Apple's abund...

Obj-C -> Incrementing a number (and showing steps on a Cocoa label)

I'm new with Objective-C, so there probably is a simple solution to this. I want a number to increment, but each iteration to be show on a label. (for example, it shows 1, 2, 3, 4, 5... displayed apart by an amount of time). I tried: #import "testNums.h" @implementation testNums - (IBAction)start:(id)sender { int i; for(i = 0...

adding multiple views to view controller inside a tab controller

I have a tabview controller to which I added a UIViewController to each tab. I want to have multiple UIViews inside the UIViewController. So in the implementation of the UIViewController class I added [self.view addSubView:uiview1] and [self.view addSubView:uiview2]. The problem is that when I run the app, it crahes on load. However, i...

How to do a flip animation between more than two UIViews?

I have animation code in a class that extends the UIView: // Start Animation Block CGContextRef context = UIGraphicsGetCurrentContext(); [UIView beginAnimations:nil context:context]; [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:[self superview] cache:YES]; [UIView setAnimationCurve:UIViewAnimationCurveEa...

How do I move the UIView to the "bottom" so that the next UIView displays?

I want to "remove" a UIView from a superview and add it again at the end... but at the "bottom" of the rest of the UIviews that belong to the superview. Is this possible? Any help is very appreciated! ...

Have you ever been barking up the wrong tree for hours?

I'm writing my first iPhone app, so there is a lot of guessing about how things work. The objC memory model takes a while to get used to. After adding some code I got stuck in applicationDidFinishLaunching. The app was crashing while sending a message to an object which I was sure should have been created at that point in the code. The...

Parsing an NSXMLElement in Cocoa

Hey all, I'm trying to use XPath to parse an XML document. One of my NSXMLElement's looks like the following, hypothetically speaking: <foo bar="yummy"> I'm trying to get the value for the attribute bar, however any interpretation of code I use, gives me back bar="woo", which means I need to do further string processing in order to o...

What is the quickest way to get the String contents of a URL using Cocoa/iPhoneSDK?

Say I want to get the HTML of http://www.google.com as a String using some built-in classes of the Cocoa Touch framework. What is the least amount of code I need to write? I've gotten this far, but can't figure out how to progress. There must be an easier way. CFHTTPMessageRef req; NSURL *url = [NSURL URLWithString:@"http://www.goog...

How to "rotate" a layer/view (e.g. just like you would in enigmo)

I know how to move a layer based on touch. But I would also like to be able to rotate the image. Is there any sample code that shows how to do this? Or can anyone give me some advice? Thanks! ...

Self-owned objects in Objective-C Garbage Collection

I'm wondering what are the recommended ways to handle situations where, in memory managed code, object didn't belong to any particular owner, i.e. objects released themselves. One such example could be a subclass of NSWindowController, which configures, displays and manages input and output of a single window. The controller object displ...

UIImage and UILabel outside UiTableView

Hi all, look at this image: I know how to add UITableView with grouped style and how to add label in any table cell. But how can I add image and labels on top on the view, like screen. ...

How can I use custom animations for onOrderOut in Core Animation?

Core Animation allows for custom animations by implementing the actionForKey method in your CALayer based class: - (id<CAAction>)actionForKey:(NSString *)key { // Custom animations return [super actionForKey:key]; } I can then create an animation and return it for the onOrderIn action (i.e. when the layer is added to another layer)....

UIWebView Expose Objective C to JavaScript

How would I expose an Objective C method within JavaScript when using the iPhone SDK when using the UIWebView? Any help would be appreciated! ...

Best way to store static reference arrays/dicts in Cocoa touch

I have several arrays of arrays or arrays of dicts that I would like to store in my iPhone app. This lists are static and won't be modified by the app or users. Occasionally they may be displayed but more likely they'll be iterated over and compared to some input value. Would the best way to store these arrays be a CoreData/SQLite dat...

Stop text from wrapping with NSLayoutManager

Given any arbitrary, one-line string, my goal is to render it into a bitmap representation. However, I have no means of finding out its dimensions beforehand, so I am reduced to getting the glyph range's bounding rect and resizing my canvas if it's not large enough. Unfortunately, if the canvas is not wide enough for the string, but ta...

How do I get the "reverse" tangent in objective-c?

I know that tan(angle) gets me the tangent. But how do I do the "reverse tangent" so that I can get the angle given the length of both sides of the right triangle? I'm assuming there is a method for this in Math.h? ...