objective-c

Objective-C Basic Class question

So I'm a bit rusty getting back into programming and I can't seem to find a good reference for understanding the structure for what I am trying to achieve. So, without further ado I am looking at creating and Class object such as. #import Assets.h @interface MainRecord: NSObject { Assets* assets; ... } ... @end Having a class...

A/Synchronous NSURLConnection: get response without download data?

Hi! Help is highly appreciated. I'm stuck here: I need to examine a response before I start loading an URL in my UIWebView. However a synchronous NSURLConnection will first download the data and then let me access the response, which is bad. An asynchronous NSURLConnection will let me examine the response before any data is received bu...

Why is my CLLocation speed so inaccurate?

Hello, I´m playing a bit with the iPhone SDK and I want to show the current speed in my Application. There are so many Apps that can do that really precise, espacially for low Speeds like running or biking. The Best I´ve seen is RunKeeper. But in my Application the Speed is absolutely inaccurate. In Low Speeds is always null and only a...

Where should I keep Core Data fetches and convenience methods?

I've got a number of convenience methods that perform fetches for my Core Data entities. For example, a method that returns currently-active activities, or a time interval between two completed activities, or a default client if there is one. I also have convenience methods to initialize and add entities with various attributes. I have ...

iphone - hiding UITabBar without presentModalViewController or pushViewController

Hey guys, like the question states, I am trying to slide in a UIDatePicker without using presentModalViewController or pushViewController and subsequently hide the main UITabBar of the application. Right now, I am adding the UIDatePicker subview with a couple buttons on a Navigation Bar to a temporary UIViewController, and initializing a...

[Objective C] Object sharing in my iPhone App

Hi, I'm currently developping my first iPhone application and I would like to know what is the best way to share an object which is gonna be used in every controller. I was thinking of referencing the controller containing the needed data in other controllers and access this data thanks to properties, is that a good idea or is there a ...

Weird Switch error in Obj-C

I have this switch statement in my code: switch(buttonIndex){ case 0: [actionSheet dismissWithClickedButtonIndex:buttonIndex animated:YES]; break; case 1: UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerContro...

Trouble with NSDecimalNumber's decimalNumberByDividingBy:withBehavior:

I always seem to run into trouble with NSDecimalNumber! Today, I get this error: "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFNumber decimalNumberByDividingBy:withBehavior:]: unrecognized selector sent to instance 0xd1fb10'" Here is the source of the error: - (void)setUpInstance { ...

What increases an object's retain count?

Here is code I am referring to. // Person.h @interface Person : NSObject { NSString *firstName; NSString *lastName; } @end // Person.m @implementation Person - (id)init { if (![super init]) return nil; firstName = @"John"; lastName = @"Doe"; } @end // MyClass.m @implementation MyClass ..... - (NSArray *)getP...

[UITableView insertSections: withRowAnimation:] causing all table cells to be requested

I'm working on modifying some existing heavy-handed code that simply calls [tableView reloadData] on any change, to using more specific table updates with the insert/delete methods. However, I'm getting some really bad behavior in doing so. Previously, as one would imagine, when the table loaded, it only requested cells for the rows th...

How to copy objects, like AVAudioPlayer

I'm rather surprised at how few objects implement NSCopying. This is the third time in two weeks where I have needed to duplicate an existing object, without having to either go to disk and reload, or recreate the object and set its settings. Now I have to duplicate an AVAudioPlayer sound. Why? I want to play the sound twice, withou...

Storing and retrieving unsigned long long value to/from NSString

Hi I have an unsigned long long value which I want to store into an NSString and retrieve from the string. Initially I have the value in an NSNumber and I am using this to get the string NSString *numStr = [NSString stringWithFormat:@"%llu", [myNum unsignedLongLongValue]]; where myNum is an NSNumber. To get back the NSNumber from t...

Filtering a NSOutlineView/NSTreeController.

How would I use a search box to filter a NSOutlineView/NSTreeController? I know it would have something to do with bindings and a predicate. But not specificaly how to. Could someone take me through the steps of filtering an NSOutlineView/NSTreeController? ...

how to customize uistatusbar in iphone?

is there a way to customize the uistatusbar??? ...

Can an objective-C NSThread access global variables?

Ok, basically I have a run loop going in my application every second or two, while at the same time I have another thread going that is looping through the listenForPackets method; broadcastMessage is only initiated when another action method takes place. The important part of this question is that when the listener thread is running sep...

How to (programatically) change slides in a running Keynote presentation?

I'm working on a Cocoa application I'd like to use to remotely (on the same machine, from a different process) control which slide is currently displayed in a running Apple iWork '09 Keynote presentation. How should I approach this? ...

UIView and UIViewController practice for inheritance

Hi, I was just wondering if this approach looks like a good practice for apps with a lot of custom views, for nested PNG graphics and animations that may change based on user interaction. I created a BaseView class that extends UIView @interface BaseView : UIView { @protected BaseViewController *controller; } @property (retain...

Why am I getting this error, when it cannot be true?

This is the error I get in the Xcode Debugger. But look here: How is this possible and how do i fix it? EDIT: ...

pointer memory management misunderstanding w/ objective-c

Hi, I'm using the iPhone SDK 3.0, but I think this is a general misunderstanding of how things work w/ c & memory management. I've overridden the viewWillAppear method like this @implementation MyViewController - (void)viewWillAppear:(BOOL)animated { NSArray *items = [NSArray arrayWithOjbects:self.searchButton, self.trashCan, nil]; ...

Objective-C @interface/pointer clarification.

Learning as always, was going along quite nicely, until I realized I had no idea what the differences meant between these. @class Player; @class Map; @interface View : NSView { Player* player_; Map* currentMap_; NSMutableArray *worldArray; NSMutableArray *itemArray; float cellHeight_; } @end Never mind, turns out...