How to check a value type?
How do I check the type of a value on runtime? I'd like to find out where I'm creating doubles. ...
How do I check the type of a value on runtime? I'd like to find out where I'm creating doubles. ...
I need to keep an NSPathControl updated with the currently selected path in an NSBrowser, but I'm having trouble figuring out a way of getting notifications when the path has changed from the NSBrowser. The ideal way to do this would just to be to observe the path key path in the NSBrowser, but that gives a KVO can only observe set<key> ...
I am programming an iPhone app, and I need to force it to exit due to certain user actions. After cleaning up memory the app allocated, what's the appropriate method to call to terminate the application? ...
Let's say I have a generic pointer in objective-c. This pointer could either be a Class object, or it could be an instance of that class. Is there any way to tell the difference between the two? Example: id pointerA = [someClass class]; id pointerB = [[someClass alloc] init]; bool pointerAIsAClass = is_this_a_Class(pointerA); // shou...
Hey folks - I'm writing a pretty simple iPhone application. The data comes from a plist file (NSDictionary basically), that I'm trying to load into a singleton class and use across my various view controllers to access the data. Here's the implementation for my singleton (heavily modeled after this thread) @implementation SearchData ...
I've got a Core Data application that has an Event class, which has a start date and a finish date. It's trivial to bind these to a pair of NSDatePicker widgets, but I wanted to make it work with the NSRangeDateMode available in Leopard. The NSDatePicker has a pair of methods that deal with timeInterval, but I don't seem to be able to ...
I am a newbie in Mac application development. I want to write a GUI application in Cocoa using Interface Builder. I want multiple screens i.e. when one button on a screen is clicked, another screen should be displayed. How can I activate a new screen at button click event? ...
When writing fairly typical Mac code in an OS X 10.5+ environment, what are the disadvantages to using garbage collection? So far everything else I've written has been either 10.4 compatible or on the iPhone, so I've become fairly comfortable with retain/release, but now that I'm working on a larger project that's 10.5 only I'm wonderin...
Lets say I have a view, myView, a view controller, myViewController, and some sort of model object, myModel. Further, lets say the model has two KVO compliant properties, arrayOfPeopleNames and arrayOfAnimalKinds (both NSStrings). In my view I want to have two pop-ups bound to the contents of these two arrays. My question is, if myCont...
I have a IBAction such as: - (IBAction)showPicker:(id)sender; How can I get the name of the control from the sender variable? I am typically a c# coder so have tried the following to no avail senderName = ((UIButton *)sender).name; I need something more descriptive than the control id (not the button title either). I have 5 button...
I'm seeing some code I've inherited that looks like the following: @interface SomeClass (private) This is within SomeClass.m, the implementation file. There is an accompanying header file which doesn't suggest that the class is using a category. Is (private) in this case just a poor name given to a category for SomeClass? And I'm assu...
Can anyone explain the differences between Protocols and Categories in Objective-C? When do you use one over the other? ...
I have a cocoa app with two types windows each of which requires a different main menu to be displayed. In my MainMenu.xib I have the default MainMenu. In Window1.xib I have Window1 and in Window2.xib I have Window2 and it's MainMenu. When I have the first Window open I have the default Menu, when I open Window2 I get it's menu. Howev...
I've written a screen saver that displays a web page. It works exactly as I want it to on my main display, but in the preview and secondary displays, the web view is hanging off the top of the screen. Example (from preview): Uploaded with plasq's Skitch! My code is pretty straightforward. From within initWithFrame:isPreview: I have ...
I have seen sample source code around that uses different ways of releasing/dealloc'ing objects, so I was wondering which way is deemed the "best" one. A few options on -dealloc: 1) Release objects - (void)dealloc { [obj1 release]; [obj2 release]; [super dealloc]; } 2) Set objects to nil - (void)dealloc { self.obj1 =...
I decided to use the GC for memory management for my latest Cocoa project, and I discovered something interesting--if I create a brand new Cocoa app project in Xcode, turn GC to supported or required (I tried both), build, and run it it leaks, it shows memory leaks! Mostly large numbers of tiny leaks of objects of type NSCFData, General...
I have an app that creates a couple of WebView instances and I'd like to have them operate as independently as possible. At the very least, I don't want them sharing cookies. A quick google search gave me results liking "you can't." I'm hoping someone has a better answer. ...
Given the following code snippet from inside a method; NSBezierPath * tempPath = [NSBezierPath bezierPathWithOvalInRect:pathRect]; [tempPath retain]; [path release]; [self setPath:tempPath]; Am I responsible for releasing tempPath or will it be done for me? The setPath is @synthesized so I probably would be able t...
I got a little stuck and I'm hoping someone can point me in the right direction. I have an NSMutableArray that stores a sequence. I created an enumerator so that a while loop can get the content of the array one by one. Everything works fine however I want the methods to be called with a 10 second gap in between each call. Right now it ...
I have a fairly standard rails app and would like to be able to access the basic CRUD (Create, Update, Delete) operations as well as queries I have added, from an iPhone app. Rails provides the REST API for these operations more or less out of the box. What is the best approach to deal with the REST/XML part on the iphone, and are ther...