cocoa

NSImage Crop Crashing

When I try to crop an image using NSImage's imageFromRect, I get an EXEC_BAD_ACCESS crash about 50% of the time. This is something that runs on startup (triggered in an awakeFromNib), so the environment shouldn't be changing. I am not sure why it crashes one one launch and not another. When I have a breakpoint set before I crop the image...

Window docking advice for Mac

Hi, I'm from a Windows programming background when writing tools, but have been programming using Carbon and Cocoa for the past year. I have introduced myself to Mac by, I admit it, hiding from UI programming. I've been basically wapping my OpenGL code in a view, then staying in my comfort zone using my platform agnostic OpenGL C++ co...

IPhone Plain TableView Section Header Image and Getting Text on Two Lines

Hello, this is my first question, so if I didn't do the tags correctly, I'm sorry. I tried... Well here is my question: I am hoping someone can tell me how to do a 2-line section header for a plain tableview. The problems I am having are: 1) I cannot find an image that will mimic that of the default 1-line section header. Can someone sha...

Objective C - Writing an NSString to a plist

Hi, I'm writing an NSString to a plist file but after its written to the plist, and when I try to open i get the following message "This document "mylist.plist" could not be opened XML parser error: Unexpected character 2 at line 1 Old-style plist parser error: Unexpected';' or '=' after key at line 1" Here is my code: NSString *te...

Cancel Cocoa Doc Based app Save method?

How can I cancel the automatic display of the Save Panel when closing windows in a doc based Cocoa app? Thanks Paul ...

Sorting NSDictionary

Hi, I was wondering if someone can show me how to sort an NSDictionary; I want to read it starting from the last entry, since the key is Date + Time and I want to be able to append it to an NSMutableString. I was able to read it using an enumerator but I don't get the results I want. Thanks ...

NSTextField - White text on black background, but black cursor

Hi I've setup an NSTextField with text color as white, and the background color as (black despite not rendering the background color, so its transparent). All in Interface Builder. The problem I am having is the cursor is black, and hardly visible. Does the cursor not represent the text color? Any ideas how I can fix this? Otherwise t...

How to Create And Display a Custom Sheet in Cocoa?

This is a newbie question! How to Create And Display a Custom Sheet in Cocoa? (like "Add Bookmark" sheet in Safari - see below) What are the steps involved in the task? How to accomplish each step? Can you point out a good step-by-step article? ...

Cocoa: Core Data relationships not working

I have a basic Core data model like this: Class -Class Name (string) Relationship: HasDetails (to many) -to Details Details -Number (int) -Name (string) Relationship: IsPartOfClass -to Class I have two table views, one for "Class" and one for "Details" and have all the bindings set up, however, when I add a new object to Details ...

Avoiding compiler warnings when doing message forwarding

I created a class that wraps a UITextView and adds some ui elements. I want the new class' API to be identical with UITextView, so I use message forwarding (listing below) to relay messages between the wrapped text view and the delegate. The irritating thing is that the compiler issues warnings for method invocations on instances of my ...

In PyObjC how do you get a sheet to end after using runModalForWindow_?

I have a secondary window (a sheet) for a dialog controlled by a secondard WindowController. For some reason, the actions never get called in NSObject subclass after the sheet is displayed. I have confirmed and re-linked the actions. The code runs to runModalForWindow_ but then never receives the ok or cancel actions. So the sheet never ...

How to programmatically retrieve table selection and table row for Core Data app?

I'm trying to make a Core Data app in which when you select one "Player" in a TableView, and a list of all teammates appears in a second tableView, with a column for how many times those two players have played on the same "Team" (another entity). This has got me completely stuck, because while I know how to fill up a table from a norma...

iPhone Memory Management with Properties of Singletons

I seem to have a fundamental gap in my memory management understanding. The code below is located within a singleton that gets called multiple times within my app to parse data that is downloaded from the web. For each article I download, I allocate a mutable string, then do tons of parsing, then write the file to the file system for la...

NSTimer with a menu bar app

I'm working on a simple timer app, and I've created a NSStatusItem with a menu and I have some NSTextField labels that updates the timer labels (http://cld.ly/e81dqm) but when I click on the status item the NSTimer stops (and stops updating the labels)..... how can I get around this problem? EDIT: here's the code that starts the timer:...

Adding a relationship with a button

I'm building a Core Data application, and I want a button to add the selected object (Player) to a relationship (Team) corresponding with that button. Add, fetch, insert? Is this a bindings issue, with Argument and Target? Thanks a ton in advance for your help, -Dan ...

NSDictionary - Printing Array

Hi, This site is great I'm getting alot of replies , so I have tried to code what I had problems with before here it is NSMutableArray *sort = [NSMutableArray arraywithArray:[dic allValues]]; for(NSString *s in sort){ [Purchases appendString:[NSString stringWithFormat:@"%@",s]]; } textview.text = Purchases; The output's ord...

Animate setContent of an NSWindow

Hi there. In the past I've been successfully able to fade in an NSWindow using the following code; if (![statusWindow isVisible]) { statusWindow.alphaValue = 0.0; [statusWindow.animator setAlphaValue:1.0]; } CAAnimation *anim = [CABasicAnimation animation]; [anim setDelegate:self]; [statusWindow setAnimations:[NSDictionary dic...

HTTP Requests in Cocoa.

Is there a good tutorial or something similar for making HTTP requests and JSON in cocoa? As I'm playing around with the Simplenote API. ...

CGImage from byte array

Loading a CGImage or NSImage from a file using a standard image format (jpeg, gif, png et.) is all very simple. However, I now need to create a CGImage from an array in bytes in memory generated using libfreetype. Its really easy to create OpenGL textures from an array of formatted bytes, and I can see how to create a CGBitmapContext t...

drawRect - reusing NSBezierPath

Hi All. I'm learning Cocoa Drawing techniques. I am creating two NSBezierPath objects from NSRects in my drawRect method, one which never changes, and one which changes width depending on something happening. So in all likelyhood, my drawRect gets called numerous times, but it seems wrong to recreate the two NSBezierPath objects each t...