objective-c

Tick/Draw Method

I'm looking for the Tick and draw method, and I'm not sure where they are. Do I have to make them from scheduler, if so how? I've heard that the draw method is only called 4 frames per second when 'paused', so does it exist somewhere? ...

Exception reporting frameworks for Cocoa

Hi, Are there any frameworks that capture and report exceptions? I need something that catches any exceptions or errors caused by my program while its being used by a non-technical user and then to email it to me. Do you handle this on your own projects? Did you roll your own solution or is there an off the shelf solution? Any help wou...

Problems invalidating & re-creating NSTimer(s)

I'm having problems starting & stopping NSTimers. The docs say that a timer is stopped by [timer invalidate]; I have a timer object declared as such .h NSTimer *incrementTimer; @property (nonatomic, retain) NSTimer *incrementTimer; .m @synthesize incrementTimer; -(void)dealloc { [incrementTimer release]; [super dealloc]; } -The u...

strange issue with memory management across threads

From a background thread, I'm jumping back into the main thread to initialize an object (because it uses UIKit), which then gets reused by the background thread (which waits for the initialization), and memory management is not acting the way I suspect. // called from another bg thread with autorelease pool - (MyObject*)backgroundMethod...

NSHTTPURLResponse statusCode is returning zero when it should be 401

Just doing a normal HTTP post with a NSMutableURLRequest and sendSynchronousRequest. But the NSHTTPURLResponse object I pass in has a statusCode of zero after the call. I get this error: Error Domain=NSURLErrorDomain Code=-1012 UserInfo=0x4d3b3c0 "Operation could not be completed. (NSURLErrorDomain error -1012.)" but no status code. ...

Creating a class with no init method (Objective-c)

Is it possible to create a class with no init method so as to force all callers to create the object with a factory method instead? ...

Object only initialisable through factory method (Objective-c)

I am trying to create an object only instantiatable through a factory method. I prevented init being used by throwing an exception (see Creating a class with no init method). However this meant that I had to create a new method secretInit to use in the factory method. //Factory method - (URLReqs *)buildURLReq:(NSString *)location { ...

Get router mac (without system call for ARP) in Objective-C

Ok - I am writing a daemon in Objective C that checks the connected router mac address every 5 seconds. I am completely new to objective C, and I am looking for a better way to do what I'm already doing. I'm currently calling "arp -a" and parsing the results via "Task": NSTask *task; task = [[NSTask alloc] init]; [task setLaunchPath...

Why [object doSomething] and not [*object doSomething]?

Hi, In Objective-C, why [object doSomething]? Wouldn't it be [*object doSomething] since you're calling a method on the object, which means you should dereference the pointer? Thanks! ...

Aaron Hillegass _Cocoa Programming for Mac OS X_ Chapter 9 Question

In Aaron Hillegass' Cocoa Programming for Mac OS X, Chapter 9, the section called "Begin Editing on Insert", he explains how to do exactly that. The thing that confused me though, was that he did a bunch of other stuff. Here's the full code listing: - (IBAction)createEmployee:(id)sender { NSWindow *w = [tableView window]; // Try to end...

CLLocationManager saying I moved 1200+ft when I'm still sitting in my chair.

I'm getting strange readings when using CLLocationManager. The Lat/Long reported are spot on, but the distance traveled is WAY off. I've implemented the following delegate method as so: .h: CLLocationManager *mLocationManager; CLLocation *mStartDistance; And .m: - (void) locationManager:(CLLocationManager *)manager didUp...

Contents of file as input to hashtable in Objective-C

Hello, I know to read the contents of file in Objective-C, but how to take it as the input to hashtable. Consider the contents of text file as test.txt LENOVA HCL WIPRO DELL Now i need to read this into my Hashtable as Key value pairs KEY VAlue 1 LENOVA 2 HCL 3 WIPRO 4 DELL ...

Searching for the Right Pattern (iPhone/Objective C)

EDIT: It was suggested to me that I implement the strategy pattern (http://en.wikipedia.org/wiki/Strategy_pattern), which I think I would do as several objects that implement a delegate protocol in Objective-C. This accomplishes the encapsulation I want while still allowing me to have a generic view controller in memory. I have a class ...

iPhone XCode - How to change title below app icon

Hi, What is the best way to rename the app so that the title below the app icon can have spaces but the build files doesn't have spaces. (ie, title is "My Project" and build file is MyProject.app) I changed PRODUCT_NAME but when I do that the app file also contains spaces. Renaming all the fields seems to work fine except I can't find...

Safe casting in Objective C

Is there anything like C++s safe casts in Objective-C? I know that they are in Objective C++, but I am unsure about possible side effects. Using Objective C++ may slow compilation time - are there any other reasons not to use it? ...

Releasing "referential" variables in method scope.

In objective-c (cocoa touch) I have a series of UIViewControllers that I am switching between. - (void)switchViews:(id)sender { UIButton *button = (UIButton *)sender; UIViewController *nextViewController; int tag = button.tag; switch (tag) { // -- has already been created case kFinancialButton: ...

How is release handled for @synthesized retain properties?

I have some questions about synthesized properties in Objective-C. The full list follows, but the basic question is this: How does the compiler ensure that the ivars for synthesized properties are properly released, even though my code may or may not include release methods in dealloc? Note: I decided not to post these as individual que...

Relaunching application via NSTask ignores LSMinimumSystemVersionByArchitecture

I'm running into an issue with relaunching my application on 10.5. In my Info.plist I have LSMinimumSystemVersionByArchitecture set so that the application will run in 64-bit for x86_64 and 32-bit on i386, ppc, and ppc64. I have a preference in the app that allows the user to switch between a Dock icon & NSStatusItem, and it prompts th...

NSTimer interval less than sleep command in fired code

I have a snippet of code I want to execute repeatedly, but with the ability to pause and resume it. To do this, I have utilised an NSTimer, which I can stop and start as required. Within the snippet, I use a sleep command to wait for something to update (0.3 seconds). The timer is firing every 0.5 seconds. What would be ideal is to k...

NSImage acting weird

Why is this code setting artistImage to an image with 0 width and 0 height? NSURL *artistImageURL = [NSURL URLWithString:@"http://userserve-ak.last.fm/serve/252/8581581.jpg"]; NSImage *artistImage = [[NSImage alloc] initWithContentsOfURL:artistImageURL]; ...