cocoa

printing 4"x6" cards in OSX (cocoa)

I'm trying to get 4x6 cards to print in Cocoa (story cards). I have a view where I put the data but when I print it prints in the correct orientation, only on 8x11 paper (in other words, it prints oriented correctly on letter size paper with the origin in the upper left corner -- lower left if you are holding the output in landscape mod...

Validate XML Schema with xsd file in Cocoa?

I have some XML and an XML Schema in a local xsd file. The XML document does not contain any schema information. I want to validate the XML document against the xsd schema file in Cocoa (meaning I'd prefer something NS/CF/libxml based as opposed to an external library). I can across xmllint, which would probably work, but I was lookin...

How to make use of sender parameter in IBAction-call

Within an action method such as - (IBAction)myAction:(id)sender { // do something } what can the sender parameter be used for? Is it possible to detect what type of click (such as left mouse down) was made on the control that invoked the action? If so how? ...

Objective C - how to resize a window programmatically with given window id?

How to resize a window of any application programmatically with objective-c / cocoa? So far I've got the app name and the window number but don't know how to access the window. I could do it with AppleScript but want to learn it with objective c. AppleScript example: tell application "System Events" set frontApp to name of first a...

Photoshop-like range selection bar in Cocoa/iPhone

I am wondering how to make the typical "range selection" bar, as seen in Photoshop and many other applications. Cocoa/Cocoa Touch only provide the very basic slide bar. ...

Sort NSArray's by an int contained in the array

I have an array, let's call it "array" and inside of the array I have objects like this: "0 Here is an object" "4 Here's another object" "2 Let's put 2 here too!" "1 What the heck, here's another!" "3 Let's put this one right here" I would like to sort the arrays by that number, so it'll turn into this: "0 Here is an object" "1 W...

Setting up Xcode for developing Plug-ins

hi. i have a very basic question. i've never worked in XCode before but i am designing a plugin (objective-c) for an open source radiology program called OsiriX. i can get the thing to compile fun and i can even get the plugin to run in OsiriX. but i'm not sure how to run/debug it from XCode. Run/Debug is grayed out on my xcode. is it be...

How do you show the Finder context menu from a Cocoa application?

I have a file listing in my application and I would like to allow people to right-click on an item and show the same contextual menu as Finder does. Is this possible? The same functionallity but for Windows Explorer is discussed in http://stackoverflow.com/questions/451287/how-do-you-show-the-windows-explorer-context-menu-from-a-c-appl...

Accessing a specific cell in an NSTableView

I have an NSTableView with some cells that where the value of enabled is set through bindings. I want to be able to change the colour of the cells depending on whether the cell is enabled or not. Previously I have done this through the NSTAbleView delegate method tableView: willDisplayCell: forTableColumn: row: which up until now worke...

cocoa: NSString not removing all the characters

I have an int and for some reason it isn't working after 16 or so. Here's my code: NSArray *sortedArray; sortedArray = [doesntContainAnother sortedArrayUsingFunction:firstNumSort context:NULL]; int count2 = [sortedArray count]; //NSLog(@"%d", count2); int z = 0; while (z < count2) { NSString *myString = [sortedArray objectAtIndex:z]...

Too much C-Style in Objective-C programs?

Hi I'm writing this question because I'm a newbie in ObjC and a lot of doubts came to my mind when trying to make my fist training app. The thing is that I have a strong background in C, I've been programming in Java for the last year and I've done some collage stuff with Smalltalk (I mencione this because those are my programming refere...

Enabling NSButton with bindings, based on NSTableView selection

I have a NSWindow containing an NSButton and an NSTableView. I'd like the button to be enabled if and only if the table contains at least one item, and exactly one item is selected. (The table does not allow multiple selection.) What can I bind the button's enabled binding to to make this happen? ...

How do I manage to draw a few images in Custom View and Drag&Drop them.

Hi everyone. I'm writting a Cocoa app. I've wrote a code that can Drag&Drop one Image. But now I need to draw several Images by double click and D&D them. Each double click- new image, each click on existing image- starts D&D. Problem is in realization. I can't imagine a simple way of realization. Can anybody propose a solution? Thanks...

Convert hex string to long

Are there any Cocoa classes that will help me convert a hex value in a NSString like 0x12FA to a long or NSNumber? It doesn't look like any of the classes like NSNumberFormatter support hex numbers. Thanks, Hua-Ying ...

Debugging a NULL CGContext under Cocoa/Carbon

During the execution of my program I'm getting the following output in the XCode debugging console: <Error>: CGContextSetTextMatrix: invalid context 0x0 I have no idea where in the application this NULL-context is being passed to the OS. Anyone know of a good technique to hunt it down? Can I break into the application when something i...

Hotkeys? Key events?

Hi, I'm trying to make a window open when the user pressed Cmd + L but how can I make my controller object listen to that particular key combination? ...

OCMock with Core Data dynamic properties problem

I'm using OCMock to mock some Core Data objects. Previously, I had the properties implemented with Objective-C 1.0 style explicit accessors: // -- Old Core Data object header @interface MyItem : NSManagedObject {} - (NSString *) PDFName; - (void) setPDFName:(NSString *)pdfName; @end // -- implementation provides generated implementatio...

Possible to reliably open AND edit an NSKeyedArchiver's archive?

I'm using something like the code below to save an NSDictionary of objects to the device. Is there a way to open this archive, drill down into the Dictionary items that it contains and, ideally, edit the data? My guess is no, not reliably, as the optimization done when saving makes the archive difficult to interpret...at least it appears...

custom NSView drawing not working

I'm trying to write a custom NSView that supports adding a background colour. I override drawRect - (void)drawRect:(NSRect)rect { [[NSColor blackColor] set]; //[NSBezierPath fillRect:rect]; //I tried this too NSRectFill([self bounds]); } And I set my custom view type to replace the content view NSView of my main wi...

Disable a WebKit WebView

Is it possible to disable all user interaction with a WebView, apart from scrolling? I want the user to be able to see the page (and possibly select things), but not click links/right click/refresh/focus form fields/trigger UI DOM events (onclick etc). I see on this question I can disable right click and selection, but that doesn't help...