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...
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...
How can I replicate the Finder's "Open With" menu for a given file type?
...
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...
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?
...
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...
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?
...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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 ...
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?
...
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
...