cocoa

Getting a color value from an image

Right now I am using a bitmap array to get a specific pixel color value from a UIImage. I couldn't find anything online other than the code from here: http://www.markj.net/iphone-uiimage-pixel-color/) Which works well enough. I wanted to know if there are any other ways to get the color for an image. Looping through myself feels a littl...

String Formatting Tricks/Docs

Was reading the response by Shaggy Frog to this post and was intrigued by the following line of code: NSLog(@"%@", [NSString stringWithFormat:@"%@:%*s%5.2f", key, padding, " ", [object floatValue]]); I know string formatting is an age old art but I'm kinda doing the end around into Cocoa/Obj-C programming and skipped a few grades alo...

Predicate for searching the first letter of each word in a string of words

I would like to create a predicate to search for a specific letter at the start of each word in a string of words e.g. all words starting with A in @"The man ate apples", would return ate and apples. Is it possible to create such a predicate? Thank you. ...

Simulating a button press without performClick: (cocoa osx/cocotron)

I need to be able to display popup menu when I press an openGL object. I was able to accomplish this by triggering the performClick: of an inviible NSPopupButton and also by triggering the performClickWithFrame:inView: of an NSPopupButtonCell. Both of these methods were successful on OSX but I also need to target the PC and unfortunat...

If the UIApplicationMain() never returns then when does the autorelease pool gets released?

For code: int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retVal; } Apple's doc clearly specifies: Return Value: Even though an integer return type is specified, this function never returns. When users t...

How do I Retrieve Relative Scores From a Subset of Entities in CoreData

Hi all, Sorry for the long question but I think it needs some background :S I have the following model in CoreData: A Guest can have any number of Scores in its scores relationship. A Score can have a maximum of two Guests in its guests relationship. For each pair of Guest entities I model have a Score entity with a value indicatin...

Portion from CGPDFPage + Scale (zoom)

I wanna take a rect from CGPDFPage (the portion of image around the user's touch point(x,y)) and scale it by a scaleFactor (ie 2x). Below the code I've used to get CGPDFPage's rect. The problem with it is the scaleFactor support. The idea is: 1) pageRect size is pageRect.size *2 2) myThumbRect (the region to zoom) become resultImageSize/...

URLCache - iPhone SDK

Hello everyone.. I need some help in using the NSURLCache to download a simple file. It would need to be saved in the Documents folder of the app. I have seen the URLCache example that apple presented, but I didn't find it useful since it was an image that was being shown. In addition there was some complex code on the modification date...

Editing Mac OS X login items in Objective-C through AppleScript

In my Cocoa program, I want to examine what programs are registered to run at startup and modify that list as I feel appropriate. In order to be compatible with Tiger it seems like I need to work through AppleScript. I currently have the following code: NSDictionary* errorDict; NSAppleEventDescriptor* returnDescriptor = NULL; NSStrin...

How can you load a font (TTF) from a file using Core Text?

Prior to OSX 10.6, ATSFontActivateFromFileSpecification/ATSFontActivateFromFileReference were available and could be used to load a font from a file. I can't find anything similar in Core Text. ...

How can I initialize a QTMovie object with certain attributes using writable data?

I'm trying to create an empty QTMovie object that I can add segments to, and then play. This is easy to do with something like: movie = [[QTMovie alloc] initToWritableData:[NSMutableData dataWithCapacity:1048576] error:&error]; I can then use -insertSegmentOfMovie to insert segments from other movies into this one so I can play it bac...

Getting better at drawing in code for Cocoa?

Hi, What are some suggested "paths" for getting better at drawing in code in Cocoa? I think at this point, that's my biggest weakness. Is drawing in code something general, or Cocoa-specific? Thanks! - Jason ...

NSOutlineViewDelegate - need something like didFinishEditing

NSOutlineViewDelegate has outlineView:shouldEditTableColumn:item: which gets called before editing a cell. I need a similar method called after the user has finished editing a cell (in order to trigger some calculations). Where should I look for this event ? ...

NSDictionary, NSArray, NSSet and efficiency

Hi, I've got a text file, with about 200,000 lines. Each line represents an object with multiple properties. I only search through one of the properties (the unique ID) of the objects. If the unique ID I'm looking for is the same as the current object's unique ID, I'm gonna read the rest of the object's values. Right now, each time I s...

Using a UITextView in a UITableViewCell with a UIKeyboard

I have a simple UITableView that has two cells. Cell 0:0 consists of a UITextField we'll call the title and Cell 0:1 consists of a UITextView we'll simply call a note. Cell 0:0 (the text field) is a standard size, one row cell. I'm therefore trying to fill the rest of the screen up with Cell 0:1 so I return a larger height for it. This a...

Dynamically populated NSPopUpButtonCell menu in an NSOutlineView

I’m working with an NSOutlineView which has two columns. My dataSource supplies the outline view with a tree of items of a custom class which represents file types (that is, you initialise it with a UTI). The first column is the display name of the file type (e.g., “Source code”, “Interface Builder NIB document”, etc.). The second column...

Put `stdout` in an `NSTextView` while running the a command

I'm creating a Cocoa Application, which will need to run the rails command. This command generates an output, and streams it to stdout. I want to show this output to the user in an NSTextView (so basicly stream the stdout to the NSTextView). My application should not 'hang' when the command is running (e.g. the git command takes a long t...

authorization services question cocoa

Sorry for being a total beginner in cocoa and for asking the following stupid question, but it's too confusing for me to google it myself or maybe i'm just missing something. I need to run a shellscript with elevated privileges in cocoa. As i understand, "AuthorizationExecuteWithPrivileges" is the correct way to do it. So i've created ...

Do autoreleased objects always survive a whole method?

Hi, If I'm correct then the releasing of the pool of autoreleased objects has something to do with the run loop.. I barely have an idea of what that 'run loop' is but my question is, is it possible that the object gets released before the end of the method is reached? ...

Most simple way to do holiday calculation?

I want to make a little free calendar program to help me and others calculate how much time we have got left in a project. I mean real working time, not just time. Time in a raw form is not saying much. Typically when my boss tells me that I have time until 05-05-2011 it doesn't tell me really how much time I have to do my job. You kno...