objective-c

Saving a list of contacts to NSUserDefaults

Using the built-in Address Book framework for iPhone, how can I save a specific list of contacts to an array in NSUserDefaults? I need to save a list of recipients for later. I want to make sure I do not run into problems if the user edits the contacts after my application is closed. Is there some sort of unique ID that each contact has...

Does NSArray copy objects?

When I make an NSArray using +[NSArray arrayWithObjects:], does it copy those objects? If I release the objects after adding them to the array, will I run into problems? ...

Programming for the iPhone with a partner far away?

How can I program for the iPhone with my friend who lives very far away? After I fix something, do I have to send the whole thing over to him and again and again and again? Any ideas? Thank you! :) ...

Convert NSNumber (double) value into time

Hey all, i try to convert a value like "898.171813964844" into 00:17:02 (hh:mm:ss). How can this be done in objective c? Thanks for help! ...

Subclassing a class, while needing to use the delegate

Say for example you want to subclass UIScrollView to create UITableView, and you don't want to use any private interfaces. In order to load cells, you must use the the parent's delegate (scrollViewDidScroll in UIScrollViewDelegate). Additionaly, you want to add some of your own methods to the delegate (e.g. tableView:willDisplayCell:for...

Objective C Delegate for the Main Application Window

So I'm trying to do this exercise where I need to set a delegate for the main window. The purpose is to make sure that when the user resizes the window, it's always twice as wide as it is high. This is my AppController.h file: #import <Cocoa/Cocoa.h> @interface AppController : NSObject { NSWindow *windowWillResize; } @end and t...

why doesn't currentLevel keep incrementing at the example

Hello all, I have a question about the next example http://www.iphonesdkarticles.com/2009/03/drill-down-table-view-with-detail-view.html Now I wonder why doesn't the rvController.CurrentLevel keep incrementing? I've build something simular and would be delighted if CurrentLevel kept incrementing. But i placed a breakpoint there and...

iphone carousel ?

Hey, is there some pattern or code to produce a carousel on the iphone? I need something like UIScrollView but that will loop when i scroll so that the first item is after the last item. people do that in javascript all the time, I'd like to do the same in objective-c. ...

Group by weekdays with Core Data

In my Core Data Model i've got an entity that has a date attribute and as the title suggests, i'd like to group this entity by (week)days. The problem is, the dates are stored more or less as timestamps and i don't know how to create a predicate that is capable of grouping/filtering my entities approprioately. I've figured out that i w...

CATiledlayer delegate not getting called

I am trying to use a separate delegate class (as many examples do) to perform the drawing of a large image in a CATiledlayer. The tiled layer has been added as a sub layer in a separate view. I first start out with a view controller. // ImageInTiledLayerViewController.h #import <UIKit/UIKit.h> #import <QuartzCore/QuartzCore.h> #import...

Can a UIViewController add itself to a UINavigationController

I'm starting an app where I'd like to have multiple view controllers. Some of the views will be displayed inside of a navigation controller. I can create a navigation controller and then add another instantiated view controller to it. But what I'd like to do, is just instantiate a view controller that has its own view and is the root ...

Scroll bars in NSTokenField

Is it possible to get scroll bars on an NSTokenField when there are too many items to display? I've tried embedding it in a scroll view but it doesn't work. Thanks ...

Hide the tab bar when displaying the ABPeoplePickerNavigationController?

I have the following code to set up and switch to the ABPeoplePickerNavigationController. ABPeoplePickerNavigationController *peoplePicker = [ [ABPeoplePickerNavigationController alloc] init ]; peoplePicker.peoplePickerDelegate = self; window = [[[currentView superview] superview] superview]; [window addSubview:[peoplePicker v...

When declaring objects in Cocoa, should I set them to nil?

Say I want to create an instance of NSString, which is initialized to a certain value depending on the value of another variable. Normally, I would do NSString *string; if(foo == 1) string = @"Foo is one."; else string = @"Foo is not one."; However, in some sample code that I've seen, I've seen people do NSString *string = ni...

How to make a real private instance variable?

I want to make an instance variable that can't be accessed from outside. Is something like that possible in objective-c? I remember Apple has private variables and stuff like that, but if people know about them, they can use them. Apple calls that "private API", but obviously others can access that stuff if they find out what's in there....

MKMapView loading all annotation views at once (including those that are outside the current rect)

Has anyone else run into this problem? Here's the code: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(WWMapAnnotation *)annotation { // Only return an Annotation view for the placemarks. Ignore for the current location--the iPhone SDK will place a blue ball there. NSLog(@"Request for annotation view"); if ([...

[NSData writeToFile:options:error:] fails, but no error object is returned. Why?

I'm trying to understand the meaning of the value returned by [NSData writeToFile:options:error:]. The method returns a BOOL, which according to Apple's documentation is "YES if the operation succeeds, otherwise NO." Fair enough, but if it's NO, I would have assumed that the error parameter would then be set to some retrievable NSError*...

Add additional input fields based on user input

I would like to allow my user to be able to say that he wants to pay out n positions in his tournament. Then be able to go in and have n fields listed and the ability to put different amounts in each one in order. I know how to do this in web code but have no idea how to do it in objective-c. Is it possible to add fields dynamically? If ...

What thread calls the delegate when using iPhone CoreLocation framework?

If I create CLLocationManager, assign it's delegate, and finally tell it to start updating, exactly which thread is calling the delegate? Some system thread? ...

Scrollable UINavigationBar similar to Mobile Safari

My application uses a UINavigationController and the final view (detail view) lets you view an external website within the application using a UIWebView. I'd like to free up some additional screen real estate when the user is viewing a webpage and wanted to emulate how Safari on iPhone works where their URL bar at the top scrolls up and...