cocoa

How to use enums with bit flags

I have an enum declaration using bit flags and I cant exactly figure out on how to use this. enum { kWhite = 0, kBlue = 1 << 0, kRed = 1 << 1, kYellow = 1 << 2, kBrown = 1 << 3, }; typedef char ColorType; I suppose to store multiple colors in one colorType I should OR the bits together? ColorType pinkColor = kW...

OpenDirectory.framework: connecting to remote servers?

I'm trying to replicate at least some of the functionality of Workgroup Manager using the NSOpenDirectory.h APIs available in 10.6. I can communicate with my local directory just fine but no matter what I try I can't establish a connection to a remote machine. Here's my ODSession and ODNode setup code. NSDictionary *options = [NSDic...

Is there an easy way to make part of an NSString object a superscript or subscript?

For example, suppose I have an NSString @"20O(2H,1H)19O", and I want all the numbers to be superscript. Is there an easy way to do this? ...

Separate key:value-string to NSDictionary

Hi, I have a string like this: "(list:\"RTM API\" status:completed)" And I want to convert it into a NSDictionary with the "value" before the colon as the key and the value left of the colon as the value - like this: list: "RTM API" status: "completed" It can probably be done using a simple regex or so, but I don't really know how...

Generate a Custom PDF layout from an NSTextView?

Problem: Users need a pdf document generated in a set font and size and a fixed number of lines per page (each line numbered). Users are entering text into a standard NSTextView. If I just choose File->Print, the default layout will render as much text as will fit onto the page, more than just 25 lines. I understand that I can use an...

NSNetServiceBrowser delegate not called when searching

I got a really annoying problem. Im trying to search after a NSNetService (that i know exist). I've copied the example code from http://www.macresearch.org/cocoa-scientists-part-xxviii-bonjour-and-how-do-you-do into my own application. I can see (in the example program) that my service is created. But when i hit search, and start a NSNe...

Getting a unique identifier for each element of NSArrayController's content

I'm making a custom view that I want to be bindings/core data compatible and represent a collection of data (a la NSTableView) Is there any way my view can refer to a specific subset of the elements in the collection (other than the current selection) after a change by the user? A bit of context: The view is going to display a number o...

How would I run an .sh file using NSTask and get its output?

I need to run an .sh file and get its output. I need to see the setup of the file as well. The .sh file simply runs a java app through terminal. Any ideas? I'm truly stuck on this..... Elijah The server.sh file: echo Starting Jarvis Program D. ALICE_HOME=. SERVLET_LIB=lib/servlet.jar ALICE_LIB=lib/aliceserver.jar JS_LIB=lib/js.jar ...

RegexKitLite replacement pattern changing case of found match

I'd like to change the case (ie, lowercase to uppercase) of found matches using RegexKitLite but don't know how or if it's possible. In PCRE regex, you can have in the replacement pattern something like \u$1 to uppercase the found match of group 1. I can't see how to do that. Can someone please let me know how? Thanks in advance ...

How do I create an NSSearchField programmatically?

I'm trying to create an NSSearchField programmatically; however, I don't know how to find the frame height of a standard NSSearchField (a la those in Interface Builder.) Obviously, I could simply copy the height from an NSSearchField entity in IB and call NSMakeFrame with that height, but that feels hackish - what happens when Apple chan...

cocoa calendar control

I found great cocoa calendar control at googlecode — http://code.google.com/p/calendarcontrol/ . Looks great , but unfortunately i can't build sources of example project. I've try resolve dependencies problem with amber.framework for several hours, but no success. Does anyone tried this control? Maybe someone have fully read build&go exa...

Objective-C: How to use both "." and "," as a decimal separator or at least convert one to another on-the-fly

I have an instance of NSTextField, e.g. someTextField, for which I will use the number formatter to limit the input to numbers only. The problem comes with the localization combined with the specific keyboard layouts used. I would like to allow both the, say, american and european users to enter their localized decimal separators. As ...

Resizing layers and its sublayers - CoreAnimation

Hi, I have a CALayer A with one sublayer B I want A to be resized (to be shrank) so I add the animations to my layer A but when I commit the animation sublayer B is not shrank. Its size remains(but its position changes as its superlayer bounds changes) How can I make my B layer to be resized along with A animation? This is what I wrote...

NSTableView and data validation?

In order to properly learn Objective-C and the Cocoa framework, I have started building a CoreData application, but I'm a bit at a loss on how to properly provide data validation when an item is being edited in an NSTableView. My model has an entity called "Business" with two string properties: a name and an issued tax number. The secon...

Names of files accessed by an application.

Hello Everyone! Any help with this problem would be fantastic. I appreciate all contributions! Let us say I'm running a daemon that is observing the behaviour of the app that has keyboard focus. I have it's PID and process name. Is there any way I can see what files that application is accessing? I'm programming in Objective-C, Cocoa ...

Sending an NSWindow object to a different class

Heya folks. Im wondering how I send the NSWindow object of the main window to a class that will do something with it. The main idea is that I press a button and then something happens to the window. (A NSAnimation for instance). fader = [[Fader alloc] initWithWindow:window]; Thats what sends the 'window' var to my Fader Class -(id)i...

xib file shows in wrong target

Hello all, I am new to using multiple targets in a xcode project and have hit a snag that I can't find an answer for. I have a project with two targets. One target does not have a user interface and the second target contains a user interface for administration. The problem that I am having is when I build and run the first target witho...

Comparing two NSMutableDictionaries

Hello fellow Computer People! I could do this myself, but was just wondering if there was a more efficient way that I haven't though of: I have two NSMutableDictionaries. Let us use these as an example: Dictionary 'Madrid' Bob : 54 Thomas : 32 Frank : 20 Dictionary 'Barcelona' Bob : 1100 Thomas : 32 Ed : 55 ...

How to change color of status bar item title in objective-C/Cocoa?

//Create the NSStatusBar and set its length statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain]; [statusItem setHighlightMode:YES]; [statusItem setTitle:@"myTitle"]; [statusItem setToolTip:@"myToolTip"]; [statusItem setMenu:statusMenu]; [statusItem setEnabled:YES]; How to change color of...

Change desktop picture in objective-c

How do you change the desktop picture in cocoa/objective-c? I've tried using defaults but had many errors. NSArray *args=[NSArray arrayWithObjects:@"write",@"com.apple.desktop", @"Background", @"'{default = {ImageFilePath = \"~/desktop.jpg\";};}'", nil]; NSTask *deskTask=[[NSTask alloc] init]; [deskTask setArguments: args]; [deskTas...