objective-c

Drawing massive amounts of data in NSView, or something else?

I have hundreds of thousands of points of time series data that I want to represent to the user. My current solution is to render said data to a PNG with a 3rd party library and then load that PNG into a NSImage and display it in a scroll view. This works great, except that: NSImages more than 32k pixels wide don't display properly ...

Keep iphone active while running program

Hi, how to set iPhone device to stay active ( to not lock ) while my app is running ? Any idea ...

Objective-C: How do I do console input?

How do I get an NSString from console input, and then try to cast it into an int? ...

How to create an NSMutableArray of floating point values

I'm new to Objective-C and iPhone development, and I'm trying to store floating-point values in an NSMutableArray, but when I do I get an error saying "incompatible type for argument 1 of 'addObject". What am I doing wrong? I'm trying to create an array of doubles that I can perform math calculations with. ...

How to add two NSNumber objects?

Now this must be easy, but how can sum two NSNumber? Is like: [one floatValue] + [two floatValue] or exist a better way? ...

On Objective-C/Cocoa Key-Value coding and arrays...

I'm trying to work out the "correct" way to handle populating an array with key-value coding for an iPhone app. I've come up with something that works, but it's fairly hackish. Basically I'm parsing an XML document into a set of code-generated models. Let's assume the XML is of this format: <foo> <bar> <item name="baz" />...

Objective-C: Why is it called 'id'?

Why is the Objective-C object type called 'id'? As opposed to, say, 'object'? ...

How do you display custom UIViews in InterfaceBuilder?

I seem to enjoy designing new UIViews and UIControls that implement their own: - (void)drawRect:(CGRect)rect; function. This work well for me, especially when composed using UIViews in Interface Builder. But composing them in Interface Builder is annoying because they just show up as boring rects with backgroundColors. Boring. It wo...

"Save" in CoreData-apps

I've here a CoreData app (no document-based), 1 entity and 1 tableview for edit/add/remove "instances" of the entity. Now I can manual add and save but I would like to a) save automaticly changes b) add automaticly some "instances" with the first start. I think a) can be solved with NSNotifications. But which to use by entities? ...

How do I dispose of my own sharedInstance in Objective-C?

If I have a class that has a sharedInstance of itself (singleton pattern) or a shared instance of another class, how do I make sure that shared instance is released properly when my program exits? Better yet, can you point me to some documentation about this? sample class (with all other methods removed for clarity): @interface Foo : N...

iPhone SDK: Record time of buttons in a sequence to play back

I've got an app in development where you press a button to play a sound using System beep. Instead of recording the output, I was thinking of recording the timing of when the buttons were pressed, so when the user presses a 'Play' button, the buttons are pressed in the same timing the user has pressed them, so it acts like the iPhone ha...

How mimic delete specific row in a TableView ?

I have a list of things in a table view. When a user tap a row, I increase score. I wish provide a way to clear the score for that row. My first try is put the table in edit mode, show the delete button to that row and proceed. However, all the other rows get blocked and can't tap again the score or tap in the disclosure button. So, o...

How build a custom control in Xcode for the iPhone SDK?

I want to build a custom control to reuse in my project which consists of two UITextFields that are linked together + a label. It is starting to become repetitive across my App and smells of code duplication ;) However, I wonder what is the best aproach here. Is it best do everything by code in a controller or is posible do a visual ...

Getting a list of files in a directory with a glob

For some crazy reason I can't find a way to get a list of files with a glob for a given directory. I'm currently stuck with something along the lines of: NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; NSArray *dirContents = [[NSFileManager defaultManager] directoryContentsAtPath:bundleRoot]; ..and...

Do I need to retain properties when using Objective-C 2.0 garbage collection?

I'm using garbage collection in Objective-C 2.0. Do I need to retain properties? Eg. @property (nonatomic, retain) NSMutableArray *myArray; Or is this enough: @property (nonatomic) NSMutableArray *myArray; I initialize the array like this: self.myArray = [NSMutableArray array]; ...

Exist any Obj-c library to integration with paypal?

I wonder if exist a pre-made objective-c library to work with paypal, including with credit-cards. My google search not get returns (I look for objective-c paypal) Also, if exist other librarys for common gateways.... ...

What is the significance of starting constants with 'k'?

I'm teaching myself Objective-C and I noticed in a lot of books and examples the use of 'k' and camel-casing in constant definition, e.g. #define kMyConstant 0 What is the significance of the 'k'? Is this unique to Objective-C style, or common to C in general? Why the deviation from (what I've always thought as a best practice) K_MY...

How do I make an OS X application react when a file, picture, etc is dropped on its dock icon?

Some applications, like Photoshop, allow users to drag a picture from a web browser, or drag a file from the filesystem, onto the application's icon in the dock. Doing this opens the file in that application. How is this done? I'd like to use Cocoa and Objective-C, but I'm interested in any solutions in any languages. ...

Can I use NSURLCredentialStorage for HTTP Basic Authentication?

I have a cocoa class set up that I want to use to connect to a RESTful web service I'm building. I have decided to use HTTP Basic Authentication on my PHP backend like so… <?php if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); //Stuff that users...

Iphone, Obtaining a List of countries in an NSArray

I have a menu that let's a user select a country. Exactly like that in the contacts.app country menu within the address field. Does anyone know a simple way of getting a list of countries? I have used NSLocale to generate an array of countries but it's only the country codes unfortunately and not the human readable equivalent. I don't ...