cocoa

Getting the list of running applications ordered by last use

I'd like to get the list of running applications in the same order they appear when doing ⌘ + ⇥ I.e. if I use TextEdit, then Preview, then iCal, the order is iCal Preview TextEdit Using [[NSWorkspace sharedWorkspace] launchedApplications] does not work as applications are sorted by launch date/process id. Enumerating with GetNextPr...

NS(Array|Tree)Controller Architecture for multiple NSViewControllers

I have a non document-based Core Data application. There's an NSTreeController that manages a collection of objects displayed in a single NSOutlineView as a source list. They are the usual kinds of things: headings, folders, smart folders, etc. Each of these container objects has a collection of contents objects. I have three separate v...

Book recomendations for learning Cocoa programming?

Hopefully this is not considered "Not programming related"... I'm an experienced C/C++/Java programmer (Also many others, but not relevant) and I'm trying to program for a mac. I've tried learning things piecemeal by looking things up as I need them online. However, I've been finding that frustrating lately. So, I decided that I want a ...

How would you make a button display a window when clicked?

How would you make a button display a window in the same Nib File when it is clicked? Sorry If This Is Vague. ...

Should "to-many" relationships be modelled as properties?

After reading the Key-Value Coding Programming Guide, the Key-Value Observing Programming Guide and the Model Object Implementation Guide, as well as reading many StackOverflow entries on the topic and experimenting with various modelling scenarios, I feel like I have a good grasp on how to model my data. I end up using declared propert...

AVAudioPlayer iPhone question

With the AVAudioPlayer, can I stream live audio from my microphone? If so, how would I do this? ...

CALayer coordinate system

Hi, I'm quite new to Cocoa, but would like to know how to change a CALayer's coordinate system. I read the article Layer Geometry and Transforms from the Core Animation Programming Guide, but still need some practical advice. The default coordinate system has (0,0) at the lower left corner. I would like to change this to the center of t...

How to determine if an NSTimeInterval occurred during an arbitrary NSDate?

Hi all, I have an NSTimeInterval, and I'd like to know whether that timestamp falls between the start and end of a date. Basically I need to be able to do something like: NSDate *today = [NSDate date]; NSTimeInterval myInterval = someInterval; [date returnYesIfFallsThisDate:myInterval]; Is there a straight forward method to figure o...

Why does NSAppleScript's compileAndReturnError always succeed?

Given that NSAppleScript objects are always supposed to run on the main thread, I created a small "proxy" object to use: @interface AppleScriptProxy : NSObject { NSAppleScript *m_script; NSDictionary *m_errorDict; } - (id) init; - (void) compileScript: (NSString*)script; - (void) dealloc; - (NSDictionary*) errorDict; - ...

Do I need to autorelease an object before sending it to NotificationCenter as a userdata?

I need to post a notification using postNotificationName:object:userInfo: method, and I'm passing a custom class FileItem in as userInfo so I can obtain it on the other end. Should I use autorelease like this FileItem *item = [[[FileItem alloc] init] autorelease]; [[NSNotificationCenter defaultCenter] postNotificationName:@"dataReceive...

Communication between Objects - Passing self to another object / Objective-C, Cocoa

Let's say we have a first Object 'Controller' and it initializes another object named 'Tasks' while passing 'self' for reference. Tasks object can now communicate and send messages to the super 'Controller' object. Is this correct for communicating between objects? Is this how its usually done? I've just started to really learn about pro...

NSArray in iPhone programming

How can I create an NSArray with values prepopulated. That is to say: NSArray *name=[NSArray alloc]; // insert these values: raju, biju.ramu Thanks and regards from raju.. ...

Notification of WebView's selection change

I'm attempting to implement a feature where a user can select some text in a WebView and, after releasing the mouse button, a small window will pop up to allow the user to perform some operations on the selected text. However, I'm running into some trouble with determining when the user's selection has been "confirmed", for lack of a be...

How can I set a "hidden" attribute for text inside NSAttributedString?

I have a Cocoa app with an NSTextView control which holds its text in an NSAttributedString (actually I believe it's a NSMutableAttributedString). I can easily set and modify different text attributes (such as font, underline, etc.) on different character ranges inside that string. However, I want to set a part of the text as hidden (si...

NSNotification/Bindings?

I am making my way thru the Hilgrass and Kochan books. Doing my own experiments to further my learning I simply want to create a cocoa interface with 4 textfields, 3 that accept numbers and the 4th that displays the sum of the other 3. I can do this using a button to do the calculation however what I want to do is have it autoupdate any ...

How do I bind the enabled binding of a button to whether or not an NSArrayController has a selection?

I want to bind the enabled state of an NSButton to whether or not an NSArrayController has any selected items. How do I do this? ...

Update bound dictionary based on NSTextFieldCell's edited value

I'm working on porting some ancient code (10.2 era) from NSCoding/plist based archiving to using Core Data. I have an NSOutlineView with a custom NSTextFieldCell. The outline view is bound to an NSTreeController to provide the data. The bindings model looks like this: NSTreeController: Managed Object Context -> Controller.managedObjec...

Changing the language for NSLocalizedString() in run time

I have an iPhone application which has a button to change display language in run time. I have looked at NSLocalizedString() which will return the appropriate strings according to system preference. What are my options rather than hard coding all the display strings and return according to user language selection in run time? Any pointer...

How to get an iphone application to resize correctly on orientation changes?

I have an iphone app, with a view (well multiple but let's say one at a time). The view is very simple just some text-fields and images on there. I have set the auto-resizing attributes for those controls so that they know that they need to be centered no matter what the orientation is. There is no code that moves them or anything, every...

How do I create a lock/unlock button and behavior in my secure preference pane?

Is there a guide out there for imitating the Lock/Unlock button and behavior of the secure Apple preference panes? (e.g. Network) ...