cocoa

How would you make a Button display a Menu when clicked?

I am looking for some code to make a Menu appear next to a button when it is clicked. What code would I need for this? Sorry if this sounds a bit vague. ...

iPhone equivalent of -doCommandBySelector:?

I want to push something onto the iPhone's responder chain. That is, I want to send a selector to a UIResponder subclass and, if it doesn't respond to said selector, have it pass it on to its nextResponder. Any thoughts? ...

register new users in openfire??

Is there anyway to register new users through an HTTP request in OpenFire. I want users to be able to sign up for my messaging service from within an app written in cocoa. Can this be done?? ...

Is it possible to have a binding that combines more than one key path?

Lets say I have an object which has a quantity value. Also, I have an array controller which holds an array of these objects. Furthermore, I have a table which has a percent of total column (i.e. the given row's quantity's percentage of the sum of the quantities for all rows), which needs to be populated with the proper value via bindi...

next-previous with large number of views

I am trying to manage 18 different views. How can I handle next-previous functionality for each view in an efficient way with this many views? ...

NSSet and NSCountedSet, when is the best time to use them?

These two collection types are rarely used by me as I'm typically using their counter parts, NSArray, NSDictionary and the equivalent mutables. I have a feeling I'm missing out on a collection which can act much faster than the other two in certain situations. When is the ideal time to use these and how? ...

why does my objective c method give me a "error: can not use an object as parameter to a method"

Hello, I've looked at this over and over again and I can't see the problem. Its probably obvious and I'm probably being an idiot and I apologize in advance for this. In my interface I have: @interface PolygonShape : NSObject { int numberOfSides; int minimumNumberOfSides; int maximumNumberOfSides; } @property int numbe...

How to typecast an id to a concrete class dynamically at runtime?

Hi everyone, I have several dataSources I use for one UIViewController. My view controller uses KeyValue Observing in order to follow the state of certain properties at runtime. When I swap dataSources, I need to stop observing those properties. The problem is, I'm not sure of the class of the dataSource at runtime, therefor something l...

Cocoa - Prevent caching of Javascript in WebKit - Safari Beta 4 bug?

I have a Cocoa app containing a WebView. I'm targeting the 10.4 SDK due to the app's installed customer base. (i.e. I cannot require Leopard.) I have two files: index.html and data.js. At runtime, in response to user input, I write over the data.js file, often, populating it with current data from the app. (The data.js file is used b...

What is the minimum boilerplate code for a OpenGL 2D View?

What's the minimum boilerplate code required to setup an OpenGL view (with the necessary projections,camera angles etc) for drawing a 2D game? For example, the minimum required to do Quartz 2D drawing in a custom view (and, say, load a background image) is the following: #import <Cocoa/Cocoa.h> @interface MyView : NSView { } @end =...

How to check for existing item in NSSet or NSCountedSet?

Hello, I'm currently populating model objects into an NSSet (perhaps I should be using NSCountedSet). The models should be unique. What I do is pull them in from a web service, and then instantiate them on the client-side and add them to a set. My problem is the following: There are times when I'll only pull one model and add it to the...

Getting title of UIButton in event handler

I create a button and set title as "Click here". When I press that button I want to get that button title and log it. Here's my code, where am I going wrong? -(void)clicketbutton { UIButton *mybutton = [UIButton buttonWithType:UIButtonTypeCustom]; [mybutton setTitle:@"Click here" forState:UIControlStateNormal]; [mybutton ad...

How do I tell NSTableView not to resize all other columns when showing/hiding a column?

I have an NSTableView, and I have the ability for the user to show or hide columns dynamically (with a mail-style header context menu). My issue is that if the table view is currently wider than it's scroll view (i.e. it's displaying a horizontal scroll bar) when a column is hidden or shown it resizes every single visible column such th...

An efficient way of redrawing a UITableViewCell once its data is available

Hi all, I currently have one UITableViewController that contains many cells with simple data in it. When the UITableViewController instantiates a UITableViewCell, it begins running a background thread for each individual cell to get its state from the server. The UITableViewCell is subclassed and already has a UIImageView property that ...

Can't include "self" in Objective-C description method?

I have a very straight forward class with mostly NSString type properties. In it, I wrote a trivial implementation of the description method. I found that whenever I try to include "self" in the description, it crashes my iPhone app. An example is something such as the following: - (NSString *)description { NSString *result; re...

How to color Text in Popup menu of NSComboBox?

Hi, I'm using a NSComboBox and want to mark some of the items in the popup list appear in red. I couldn't find a proper Method to override in NSComboBoxCell. Any idea? ...

What are some unique uses of NSLog you have used?

Do you have any unique or special uses of NSLog you use for debugging? ...

How do I override NSError presentation when bindings is involved?

One thing I've always had trouble with in Cocoa Bindings has been error presentation, for example when the user types the wrong value into a text field with a formatter attached. Normally I would override willPresentError: somewhere in the responder chain, but my problem is the NSError objects created by the Bindings system doesn't conta...

Producer Consumer Issue with Core Data

I've a Core Data application. In the producer thread, I pull data from a web service and store it in my object and call save. My consumer object is a table view controller that displays the same. However, the app crashes and I get NSFetchedResultsController Error: expected to find object (entity: FeedEntry; id: 0xf46f40 ; data: ) in s...

iphone cocoa "error:request for member ____ in something not a structure or union"

this way works: type1ViewController *viewController = [[type1ViewController alloc] initWithNibName:@"Type1View" bundle:nil]; viewController.parentViewController = self; self.type1ViewController = viewController; [self.view insertSubview:viewController.view atIndex:0]; [viewController release]; but this way gives me the error, "request...