cocoa

Call another program's functions?

So I have this program that I really like, and it doesn't support Applescript. I'd like to automate it a little bit. Now, I know that I could use applescript to tell the program to tell the menu to tell the submenu to tell the menuitem to activate or whatever, but frankly I don't like applescript very much anyway. When I open the NIB fi...

Why isn't there NSArrayController for the iPhone?

Why isn't there NSArrayController for the iPhone? Will there ever be an NSArrayController for the iPhone? ...

Iphone Object C - Data,Objects and Arrays

So I'm a Flash guy and I'm trying to convert the following code to Object C: var slot:Object = new Object(); slot.id = i; slot.xPos = 25*i; slot.yPos = 25*i; slot.isEmpty = False; // push object to array arrGrid.push(slot); Later I can override like: arrGrid[0].isEmpty = True; I can't ...

How does one properly lay out a standalone system service in Xcode?

I've recently become interested in writing some system services for OS X but since I have no application to advertise the services under I must resort to writing standalone system services. Apple's documentation on System Services is spartan as it is, but its documentation on standalone services is non-existant. What I have thus far is ...

Core animation anchor point being ignored?

This code: (self is a subclass of NSView) rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotate.duration = 5; rotate.toValue = [NSNumber numberWithFloat:(2*pi)]; rotate.repeatCount = INFINITY; rotate.removedOnCompletion = NO; rotate.fillMode = kCAFillModeForwards; NSLog(NSStringFromPoint(CGToNSP...

Why am I getting an error for this?

Why am I getting these errors? It says: Error: Request for member "jokeTableView" in something not a struction or union What does that mean? And why is it breaking. I tried reading about initWithStyle but I just could catch up on it Here is my .h file: #import <UIKit/UIKit.h> @interface TableViewController : UITableViewContr...

Basic Obj-C question: Calling methods on an object

Background: I'm a .NET guy who has no prior experience in Objective-C/Cocoa, but I'm working through Aaron Hillegass' book, "Cocoa Programming for Mac OS X" trying to pick up the basics. (Great book so far, BTW!) For the purpose of completing one of the optional side challenges, I'm writing a document-based app that lets users draw ovals...

How can I make a set of constants, to improve the usabilty of my methods?

I've written an method that does some graphics calculations. There, you can specify a start-direction like "from left", "from right", "from bottom", "from top". Now I don't want the user of my method to pass confusing values like 1, 2, 3 or 4 or even strings. Nothing like that. Instead, I would like to create constants like: kFromLeft,...

How do I find the pixel position of a character in an NSTextView?

I'm currently using the following code to fetch the logical NSView position of glyphs which is working fine however it seems a bit slow and the positions aren't precisely on the character kerning point and baseline. It very well may be the case that all I need to do is iterate the glyphs themselves one by one and build the rect myself. ...

Read input from a cocoa/foundation tool console?

I wonder if Objective-C/Foundation has any special commands for reading user input from the console. Since it has NSLog for output maybe there is something else I could use instead of the scanf command. I need to read some numbers (user input) into my tool. What is the best way to get these input in types like double or int? And how do ...

BWSplitView and PyObjc

I'm trying to use Brandon Walkin's BWSplitView from BWToolkit in a Cocoa PyObjc project. When I run the project I get the following error message: NSInvalidUnarchiveOperationException - *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (BWSplitView) Does this mean his toolkit is incompatible with a PyObc proj...

Releasing Core Foundation object references

Do I need to release a Core Foundation objects to clear up memory? And if so, how? For example, in the code: ABAddressBookRef addressBook = ABAddressBookCreate(); CFArrayRef peopleArray = ABAddressBookCopyArrayOfAllPeople(addressBook); do I need to release peopleArray? What about addressBook? ...

Cocoa: Why is my table view blank?

Why is my table view blank? It was fine until I added "initWithStyle" Here is what it looks like: And here is what my code looks like: Here is my .h: #import <UIKit/UIKit.h> @interface TableViewController : UITableViewController { NSMutableArray *jokes; IBOutlet UITableView *jokeTableView; } @property (nonatomic, retain) NSM...

Just in theory: How is the alpha component premultiplied into the other components of an PNG in iPhone OS, and how can it be unpremultiplied properly?

Actually, I thought that there would be an easy way to achieve that. What I need is pure alpha value information. For testing, I have a 50 x 55 px PNG, where on every edge a 5x5 pixel rectangle is fully transparent. In these areas alpha has to be 0.Everywhere else it has to be 255. I made very sure that my PNG is created correctly, and i...

Do multithreading and autorelease pools work together in Cocoa?

I would like to send an object back to the main thread from worker thread. However do auto-release pools work between threads? Is there anything wrong with the following code: -(void)mainThreadReceiveResult:(id)response { [response retain]; /* Do some stuff with response */ [response release]; } -(void)workerThreadDoWork { N...

How do I create a nice -description method that nests recusively like NSArray

The -description method for NSArray will nest recursive calls as in: 2009-05-15 14:28:09.998 TestGUIProject[29695:813] ( a, // Array1 item 1 ( // Array2, a second array, nicely indented another 4 spaces a // Item in Array2 ) // End of Array2 ) // End of Array1 I want to do something similar for my own custom cl...

Create drag-drop graphic when installing OS X application from dmg

A lot of applications on the mac show a little graphic when the installer DMG is initially opened - the graphic basically allows you to drag and drop the app in that window without having to do it in finder (I'm not talking about package manager here). Any idea if there's a standard way to create that type of experience? ...

Code sample for capturing audio from a Mac in Cocoa and saving to file?

I'm due to work on a small application that captures audio from the Mac's Audio Queue and needs to save it to disk in some reasonable audio format. Does anyone have a some decent sample code (Cocoa / Objective-C) that they can share? I specifically need to capture the audio that is being passed to the Built-in Output device in order ...

Core animation code structure/conventions

In learning Core Animation, I learned very quickly that if you don't do it right, you get really weird undefined behavior. To that end, I have a few questions that will help me conceptually understand it better. My NSView subclass declares the following in it's init. This view is a subview of normal layer backed view. [self setLayer:[...

Rename file in Cocoa?

How would I rename a file, keeping the file in the same directory? I have a string containing a full path to a file, and a string containing a the new filename (and no path), for example: NSString *old_filepath = @"/Volumes/blah/myfilewithrubbishname.avi"; NSString *new_filename = @"My Correctly Named File.avi"; I know about NSFileMa...