cocoa-touch

How to make a superview intercept button touch events?

Say I have this code: #import <UIKit/UIKit.h> @interface MyView : UIView @end @implementation MyView - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { // How can I get this to show up even when the button is touched? NSLog(@"%@", [touches anyObject]); } @end @interface TestViewAppDelegate : NSObject <UIAppli...

Using PubSub Framework in iPhone Apps

Is it posssible to use the Publication Subscription (PubSub) Cocoa framework in iPhone apps? I understand that the subscription features would not be available, but is it possible to use the feed-parsing features? (These would be very handy, since they handle multiple versions of RSS and malformed feeds.) ...

Custom Uisegmentedcontrol

How do I make a custom UISegmentedcontrol. I have 2 images, 1 that should be displayed when the segment is active and the other if the segment is inactive. Can i override the style or something so i have a UIsegmentedcontrol with my own images as active/inactive background? ...

Autorotation of CALayer on iPhone rotation

I have a UIViewController where I am adding a CALayer subclass to the view's layer: [self.view.layer addSublayer:myObject.backgroundLayer]; When I rotate the device, the view rotates, but the CALayer doesn't. It sort of gets shunted off to the left, still in portrait view. Is there a way to make sublayers rotate automatically or do ...

iPhone Exception Handling

I have one crash in my iPhone application that does throw an NSException. The crash reports are completely ambiguous in where the error is and what exactly is causing it. Is there a smart way for me to set a top level exception handler somewhere to see what is causing it? I can't replicate the problem myself, but a few of my beta users c...

KVO rocks. Now how do I use it asynchronously?

I am sold on KVO but if used in the obvious way it is synchronous. I would like to use it in a situation where I am firing off many KVO messages in rapid succession and it is causing my app to grind to a halt as the KVO messages are handled. Can someone suggest an approach - perhaps using NSOperation or NSThread - that will work here. M...

iphone string manipulation

I have the following string.... Overall: 21 (1,192,742<img src="/images/image/move_up.gif" title="+7195865" alt="Up" />)<br /> August: 21 (1,192,742<img src="/images/image/move_up.gif" title="+722865" alt="Up" />)<br /> I need to remove the HTML tag, is there a way I can say remove everything between ??? ...

Where's the difference between [MyClass alloc] and [[self class] alloc]?

Is there a good reason why I should not do something like this? Example: I have a class MyClass. In there I have this implementation: - (id)copyWithZone:(NSZone*)zone { MyClass *copy = [[MyClass allocWithZone:zone] init]; copy.someproperty = [[self.someproperty copy] autorelease]; return copy; } Instead of that, I found a...

Generating HTML programmatically

In C#, I use XML/XSLT transformation to isolate markup from data. What's the equivalent in Objective C? ...

Is there a cocoa library for advanced date + time handling?

I need to do some date + time stuff that is not covered well by NSDate on the iPhone. I wonder if there is a library that has more sophisticated functionality regarding dates and time on a international level. What I want to do is advanced date + time mathemathics. I need to: convert between different calendar types (Gregorian <> Jewi...

Property Lists: How to use it to provide easy exchangeable default data to the user?

I want to ship some default data with my app. This data can be stored perfectly in a property list. The strucure is simple: Root 0 animalType = cat animalName = Tom 1 animalType = dog animalName = Rambo I thought: When I use a property list rather than hard-coding it somewhere, then I could easily provide m...

Do I have to autorelease this object?

I am creating an NSDictionary with -initWithObjectsAndKeys:. For every object I provide to that dictionary I call a selfmade method -createFooBarObject, which will create and return the object. Now the problem: The create method by definition should not release the object because it must return it, and the caller is responsible for rel...

How do I pass a number / integer between view controllers?

I am having difficulty with numbers when programming my iphone app. I want to pass a number (and possibly eventually an array) from one view controller to another. I have managed to do this will strings but I just can't figure it out with numbers. This is what I have.. PrimaryViewController.h @interface PrimaryTimerViewController ...

What is the difference between these two init methods?

As far as I know, the first one you have to release when you are done, and the second one you don't. Why would you use the first initialization over the second? NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"title", @"text", nil]; And NSMutableDictionary *dictionary = [NSMutableDictionary dict...

How to edit an default Xcode template?

When I create an NSObject subclass, I always get an empty implementation. There are some things I always put in my code like pragma marks and -dealloc methods. I prefer to just delete stuff that I don't need over writing it with typos from scratch every time I need it. I need -dealloc and -init almost always, but they don't ship with the...

Transition from a UITableViewController to a UITabBarController

For aesthetic reasons, I'd like the initial controller of my iPhone app to be a UITableViewController. But, in response to a row selection, I'd like to display a UITabBarController. Is this possible? Can one transition from a UITableViewController to a UITabBarController? ...

Bug in XCode debugger?

I am working on an iPhone app which is using an external library for which I have the source. During debugging some of the objects are listed as 0x0 in the debugger but the app runs fine. Also, some of the objects addresses point to the wrong thing. These symbols are in the external library. The addresses are fine if I am tracing throug...

Document Directory on iPhone is invalid

I attempt to get the path of the document directory on the iPhone SDK with the following code: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); I'm in distribution and not debug configuration. In debug a valid path is returned. Also I'm using iPhone OS 3.0 Please help! Joe ...

How to make a subview tint a portion of the screen on the iPhone?

I would like to write a UIView subclass that, among other things, colors whatever's underneath it a certain color. This is what I've come up with, but it unfortunately doesn't seem to work correctly: #import <UIKit/UIKit.h> @class MyOtherView; @interface MyView : UIView { MyOtherView *subview; } @end @implementation MyView - (id)...

Keeping lots of localized content in sync

If you localize for a number of languages and have lots of content, how do you keep any changes in sync? For example, a bird app that list various birds (200 of them). If you have chosen to localize for five languages, that means you need 1000 localization files. Not only is it a lot of initial translating but very time consuming to k...