cocoa

Synchronizing producer, consumer and a producer queue.

Hello! I have a producer and a consumer. Producer fills its internal queue with objects, consumer takes these objects one by one. I want to synchronize the cosumer with the producer, so that the consumer blocks when there are no objects ready, and I want to synchronize the producer with itself, so that it stops producing when the queue i...

Application crash when user is making edits to a table view and data gets refreshed in it.

Hi all, In my application I have taken certain table views, their data gets refreshed in background thread if a user makes and save changes. Problem is- when user is making some edit to a table row and its data gets refreshed in background, due to changes done by some other user, then the application crashes. Can anyone...

Find out the "Open With" menu items in Finder

How can I replicate the Finder's "Open With" menu for a given file type? ...

arrayWithContentsOfFile: results in crash.

I am creating an application and I get an EXC_BAD_ACCESS error. CODE @interface DNProjectsCategory : DNCategory { NSArray *projects; } @property(nonatomic, retain) NSArray *projects; @end And: @implementation DNProjectsCategory @synthesize projects; // MEM - (void)dealloc { [projects release]; [super dealloc]; } // INI...

Limit scope of NSMetadataQuery

Hi, I was trying to restrict the scope of a NSMetadataQuery item. I know there's the -setSearchScope method, but it lets me only decide in which directories the item will search. What if I need to exclude one or more directories from the scope? ...

Core Data: sorting by count in a to-many relationship

I am currently trying to setup a NSFetchedResultsController that will order my table view based on the number of entities in a to-many relationship. I am not sure if this makes a difference when counting, but this is also an inverse relationship. I thought something like this would work just fine: NSEntityDescription *entity = [NSEntit...

Cocoa: Does there exist an NSView with user resize capability?

I want an NSView that can be resized by dragging its the bottom right corner around, just like an NSWindow. I want to be able to embed this NSView into a parent NSView. Is there a component like this in Cocoa or any of its extensions? ...

How do I output a literal sequence with NSLog

I want NSLogto output a literal escape sequence, without treating it as a pattern. Take, for example NSLog(@"image%03d.jpg");, who's output I want to be the actual contents, image%03d.jpg instead of image000.jpg. I've tried various escape sequences like NSLog(@"image\\%03d.jpg");, NSLog(@"image\\%03\\d.jpg"); and NSLog(@"image%03\\d.jp...

Core Data set Attributes

Hi there, I'm trying to set attributes with Core Data but it won't work. Every time I call the mehtod setAveScore it throws the error [Stats setAveScore:]: unrecognized selector sent to instance 0x3364c0 Any idea what is going wrong? The call: Stats *sObj = [Stats alloc]; NSNumber *foo = [[NSNumber alloc ]initWithInt:1]; sObj.aveScor...

Repeating background image in an NSView.

I am trying to draw a repeating background image in my NSView, I have this till now: // INIT - (id)initWithFrame:(NSRect)frame { if (self = [super initWithFrame:frame]) { self.backgroundImage = [NSImage imageNamed:@"progressBackground.pdf"]; } return self; } // DRAW - (void)drawRect:(NSRect)dirtyRect { // Draw the backgrou...

Accessing an object outside scope in a controller class

In my controller class, I initialize two instances of a model class (whose header is properly imported into controller class) with an NSButton. The model is really simple, just 4 members and one method - attack(). Making a silly text game! - (IBAction)startGame:(id)sender { Combatant *hero = [[Combatant alloc] init]; Combatant...

Loading NSView from NIB won't work.

I have this code to load an NSView from a NIB and add it to another NSView: // INIT - (void)awakeFromNib { // Load nib DNListViewController *listViewController = [[DNListViewController alloc] initWithNibName:@"ListView" bundle:nil]; // Add view to window [listViewController.view setFrame:detailView.frame]; [detailView addSubv...

Objective-C's dynamic advantages in Cocoa development?

So from my understanding (one of) the biggest allures of Obj-C is the dynamic, message-passing runtime. How's this and other features overall beneficial to Cocoa development? Why was Obj-C used for Cocoa dev and not C++/C? Basically I'm trying to understand how such language features are actually beneficial in terms of when actually...

Why is -[NSPasteboard writeObjects:] returning NO for an array of NSURL objects?

I have an NSArrayController that I'm using to provide data to an IKImageBrowserView. I want to support drag and drop from the IKImageBrowserView to other applications. Here's the relevant method from my code: - (NSUInteger) imageBrowser:(IKImageBrowserView *) aBrowser writeItemsAtIndexes:(NSIndexSet *) itemIndexes toPasteboard:(NSPasteb...

Starting a Cocoa document-based application shows selection window first.

This seems like it should be easy yet I must be missing something. I have a document-based application. I have also built a new XIB that has a NSTableView and three buttons on it that I intend to display a list of previous files. I wish this XIB to be displayed instead of the document window when the application first starts. Once th...

Loading an image to an OpenGL texture using Cocoa

This seems like it should be something that's easy to do, but I can't seem to find a source out there to tell me how to do it. I would like to load a texture from an image file into my shader. I'm trying to stick as close to the core profile as possible in OpenGL 3.3, although I understand a lot of things are still not implemented in O...

NSImage coordinate

hey guys, I have a large image, and then i'm extracting a portion of the image out via: [mBaseImage lockFocus]; NSBitmapImageRep* bitmapImageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(startX,startY,width,height)]; [mBaseImage unlockFocus]; followed by: extractedImage = [[NSImage alloc] initWithSize:[bitmapIma...

How to determine the startdate (monday) of a week with a predefined date?

My example date is 08.10.2010 (friday), so the startdate should be 04.10.2010 (monday). NSDate *today = [[NSDate alloc] init]; NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *weekdayComponents = [gregorian components:NSWeekdayCalendarUnit fromDate:today]; NSDateComponents ...

Conversion NSString to NSDate. 1 day is lost.

NSString *dateString = @"20.10.2010"; NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@"dd.MM.yyyy"]; [dateFormatter setLocale:[NSLocale currentLocale]]; NSLog(@"%@", [dateFormatter dateFromString:dateString]); My output is: 2010-10-19 22:00:00 GMT Why is one day lost? ...

Preprocessor Timestamp

Is it possible to generate an embedded Unix timestamp via a preprocessor macro? For instance: #define VERSION_EXPIRE __TIMESTAMP__ The reason for this is, that i have beta versions and i want to generate an expire timestamp on compile time (in a special Debug build configuration). Regards, Erik ...