cocoa

Background image for a window in Cocoa framework

I am looking for a perfect solution to set a background image for a window in a cocoa application. I haven't found a solution to this, I am new in objective c, so please anyone help me... ...

How to get notifications of NSView isHidden changes?

I am building a Cocoa desktop application. I want to know when a NSView's isHidden status has changed. So far using target/action doesn't help, and I can't find anything in NSNotification for this task. I would like to avoid overriding the setHidden method, because then I'll have to override all the NSView derived class that I am usin...

How would you put an Image next to a text cell for only parent rows in an outline view?

I am looking to have an image next to a text cell for only the parent rows in my Outline View. Like what they have in Xcode: . How would you do this or would you need a Custom Cell? ...

change innerHTML of cocoa DOMElement

Objective-c, Webview Hello, I'm trying to change the innerHTML of an DOM elemnent in a DOMDocument: DOMDocument *myDOM = [[storyDisplay mainFrame] DOMDocument]; DOMElement *heading = [myDOM getElementById:@"heading"]; [heading setNodeValue:@"hejsa"]; Nothing seems to change when the above lines are executed, is this the right w...

How do I log to file on the Mac (similar to log4net)

For my Mac app I'd like to create a log file on disk similar to those produced by log4net windows side. Things I'd like include a date stamp, logging levels (Debug, Info, Warning, Error), etc, and I'd prefer not to have to roll my own from scratch. Both VMWare fusion and JollysFastVNC do something similar to what I'm looking for, albeit...

Sorting an NSMutableArray with custom objects 'overwrites' some objects

For a little iPhone application I am making, I want to sort a NSMutableArray. I found 2 ways of doing this, but they both result in the same thing. Sorting the array will cause some objects to 'overwrite' eachother. First off, here is my code: AppDelegate.h NSMutableArray* highScores; Somewhere down that AppDelegate.h, I also make ...

How to word wrap text?

In Cocoa, there is a method (lineBreakBeforeIndex:withinRange:) on NSAttributedString to find appropriate line breaks in a piece of text. Since NSAttributedString does not exist on the iPhone, does anyone have any suggestions for similar functionality? Edit: Realized that I'm really looking for a word-wrap algorithm. For example, I wan...

Cocoa: filling an NSBezierPath with an image

I'm trying to find out how to draw a path, and then fill it with content from an image, e.g. a .png. I have tiles of various shapes (square, triangle, etc., each defined by an NSBezierPath. I can fill them with solid color, but I also want to be able to fill them with some kind of bitmap image instead of solid color. ...

NSView's autoresizing behavior

Greetings all, I hope you all can shed some light on how NSView autoresizes it's views. I've set everything up in IB and my subviews resize nicely (when I resize my window around with a mouse). However, if I do [myMainView setFrame:] with my new frame rect, nothing happens. All of my sub-views are still the original size (even though t...

Cocoa bindings: custom setter methods?

I'm using Cocoa bindings to manage a table of objects. I understand how bindings work but I've run into a slight problem. Managing the table of objects would be fine and dandy, except that those objects have to manage actual bluetooth hardware. I'm working off of a framework that provides a class representing a connection to this hardwar...

Adding a custom view to a window in Cocoa

Hi all, I am creating a sample application for Mac OSX. I created a window which contains a login button and I added a new custom view. Now I need to load the custom view to the window when the user clicks the login button. Please anyone help me... ...

NSLog tips and tricks

Hi, I'm doing a presentation on debugging in Xcode and would like to get more information on using NSLog efficiently. I'd like to know if there are any tips and tricks to using NSLog which you guys have picked up. For example, is there a way to easily NSLog the current method's name / line number? is there a way to "disable" all NSLo...

UINavigationController and autorotation.

I have a UIViewController that returns YES in shouldAutorotateToInterfaceOrientation: for UIDeviceOrientationPortrait and NO for everything else. With that view on the top of the stack, I use pushViewController:animated: to push a new UIViewController. The new controller returns YES for anything in shouldAutorotateToInterfaceOrientation:...

Cocoa Keyboard Shortcuts in Dialog without an Edit Menu

I have an LSUIElement application that displays a menubar status item. The application can display a dialog window that contains a text field. If the user right-clicks/control-clicks the text field, a menu appears that allows cut, copy, paste, etc. However, the standard Command-X, Command-C, and Command-V keyboard shortcuts do not wor...

Can a NSArrayController in entity mode serve as a delegate? How?

Hi, I'm trying to us a NSTokenField as a representation of a to-many relationship in Core Data. Since binding it directly appears to be impossible, I want to use its delegate method -(void) controlTextDidEndEditing:(NSNotification *)aNotification; to ring up the array controller, who should then do all the dirty work of inserting/delet...

Where to put project files?

When I first started using Xcode, I didn't like the default project files location. Instead, I made a folder in my user directory instead. Now, I think that is a mistake, since I now link to libraries in my user folder. If I share code with someone, it breaks (since my user folder isn't located on their machines). What's the best prac...

Syntax Highlighting in Cocoa TextView? Experiences? Suggestions? Ideas?

I'm interested in syntax highlighting in a Cocoa TextView. I found several resources: approach with flex, via a flex pattern matched against textStorageDidProcessEditing in a TextView delegate. In this approach the whole string get parsed on each input event, hence performance degrades. CocoaDev has an own page on the topic of syntax ...

How to get notified of changes to models via an NSArrayController?

I have an NSView subclass which is bound to the arrangedObjects of an NSArrayController. When the array has an item inserted or removed the view is notified. How do I get it to be notified if a model stored in the array has an attribute changed? Do I need to add my view as an observer to every (relevant) attribute of every item added to...

How do I localise the default value of attribute in a Core Data Entity

If I was creating an entity with a non-optional string attribute called, say, "name", I would put "Untitled" as the default. How could I localise this default value? I could subclass the entity and and use NSLocalizedString in awakeFromInsert to do this. But I was wondering if there was another way. Edit: If this is the only way, then...

Setting value of AXTextField programmatically (OS X Cocoa Accessibility API).

I'm using the Cocoa Accessibility API to try and modify the value of a text field (AXTextField) in another application, but I've run into a problem: my code correctly identifies and modifies the contents of the text field in question, and the text of the field visibly changes, but the changes aren't registered by the program I'm trying t...