cocoa

How can I make a box's edges smooth without anti-aliasing?

I'm creating a dice game for the iPhone. I'm using SIO2 as engine, but I think this question is more general OpenGL-related. Since the iPhone lacks support for anti-aliasing, my dice looks kind of edgy. If possible, I'd like to make the edges of the die rounded and smooth instead of sharp. I've found one app, MotionX, that manages to d...

Cocoa and getting out of infinite loops

Hi, The basic idea I have is to click on one button and enter an infinite loop. I plan to click on another button to stop and get out of this loop. Trouble is once I get into the infinite loop, my second click is never detected so I can't get out. Any idea's on how I can get this to work ? Thanks a ton. -(IBAction) startButton { while...

Hide menubar and dock after fullscreen video in WebView

I have a cocoa application which is a fullscreen webbrowser using WebView. Initially the menubar and dock are hidden, and cannot be accessed, which is how I want it, but after a fullscreen window such as a video is displayed, the menubar and dock reappear and stay there. Any idea how to prevent them from reappearing? ...

making class members properties and synthesizing them

Is it safe to say that if a class member does not need getter or setter functions then there's no point in making them properties and synthesizing them? ...

How to update a variable in one class from another?

I need to set a variable in Class A from Class B. To test this, I have a while loop running in Class A that continuously prints the variable via NSLog. However, no matter what I try, I cannot get Class B to update the variable in Class A in such a way that Class A can read the changes made by Class B. I am pretty sure I have everything h...

What actually is a @selector?

There are some functions which take as an argument @selector(methodName). I used NSLog to find out what @selector is, and it returns an integer. It looks like a PID, but when I ran ps ax that PID could not be found. What does that integer represent and why do we have to use @selector all the time instead of just passing the method name? ...

form load in cocoa

hi all, I want the date shown for when the form is loaded ,what can i do? NSDate* now = [NSDate date]; NSDateFormatter * f = [[NSDateFormatter alloc] init]; [f setDateFormat:@" EEEE YYYY/MM/dd "]; [date_en setStringValue:[f stringFromDate:now]]; i want to display this in window but not in the buttons a...

Where i find a list of Key Equivalent strings on MacOSX

I need to know which NSString values i can use for key equivalents. I can't find out what to use for cursor keys delete/backspace function keys numpad items ...

Example code for a minimal paint program (MS Paint style)

I want to write a paint program in the style of MS Paint. On a most basic level, I have to draw a dot on the screen whenever the user drags the mouse. def onMouseMove(): if mouse.button.down: draw circle at (mouse.position.x, mouse.position.y) Unfortunately, I'm having trouble with my GUI framework (see previous question)...

Does this Objective-C code leak memory?

One thing I'm concerned about is I create two ints, but don't release them. Would it be better to make them NSIntegers? -(void) flipCoin { int heads = [headsLabel.text intValue]; int tails = [tailsLabel.text intValue]; if (random() %2 ==1 ) { heads++; } else { tails++; } headsLabel.text...

problems with creating an NSWindow

Hi, I am new to Cocoa, and I am just experimenting with creating a window programmatically (without using Interface Builder). I start a new Cocoa Application in Xcode, then I remove the window from the nib file in Interface Builder to replace it with my own one. In the main function, I add the code: NSWindow* myWindow; myWindow ...

Resizing an NSView smaller than its subviews?

Couldn't find anything on the net about this; and wondered if anyone on SO has a solution. I have an NSView with several subviews that are centered by removing the left and right anchor points. When I resize my view, programatically or with the mouse, to a smaller width than the subviews: it pushes them off center. Has anyone come acros...

Call IBActions through different XIBs

Hi there. I put a NSMenuItem in the MainMenu.xib of a document-based application. I can set a key equiv. for this item in Interface Builder, anyway that item can't call an IBAction defined in the NSDocument subclass instance (which exists in MyDocument.xib). How can I make that button call an action from a different xib (if it is possib...

NSString initWithData returns null

I am pulling data from a website via NSURLConnection and stashing the received data away in an instance of NSMutableData. In the connectionDidFinishLoading delegate method the data is convert into a string with a call to NSString's appropriate method: NSString *result = [[NSString alloc] initWithData:data ...

What should I use to control input devices and more

Hi, I am fluent in C++, Java, and Python and can pretty much pick up any other skill given enough time (no surprise there, I'm sure 99.9% of the people reading this share the same ability). I have an idea for a small app for Mac OS X and I was wondering what technology I should employ/learn to get it working. I need some minimal OS X ...

Using NSPopUpButtonCell with NSTableView

Hello I am trying to use a NSPopUpButtonCell inside an NSTableView. Basically when you select an item in the pop up I want it displayed in the table view column/row. When an item in the popup cell is pressed I store it inside the data source using "tableView:setObject:forTableColumn:row", then when the table requests data I retrieve and ...

Key Value Coding Primitives

I have some automatic de-serialization code that will set an object's properties using KVC. I need to add de-serialization support for primitives (int, double, float), but I am unable (or unsure of how) to use "setValue: forKey:" with primitives. The property lookups must be performed at runtime. Any ideas? Thanks. ...

Preventing re-entering observeValueForKeypath recursively when KVO fired from model setter

I have a whole host of models that watch themselves for changes. When a setter is triggered, the observer in the model is called and within that model I make a call to a web server and update information in the web server so it correctly has the data it should. However, in my call to the web server I can get back an error for anything f...

How to properly return a value from a method and have it available immediately after application loads?

Hello everyone, first post here so sorry for the length of it. I've been lurking and learning a lot so far but now I have to step in and ask a question. I have read numerous posts here as advised in the FAQs, but I couldn’t find exactly the answer I’m looking for. Before anything else, let me just say that I'm a total beginner in progr...

Showing serial nos. in a table column using NSArrayController and cocoa bindings

Hi all, I have a simple question: How to show serial nos. or (row no. + 1) in a table column using cocoa bindings and array controller? I have made an application using cocoa bindings and array controller, in which I am displaying names of certain persons in a table column. The class from which I am displaying is named as: Perso...