cocoa

Creating an NSImage from bitmap data

Ok, it appears that the I'm creating a PDFDocument where pixelWidth is incorrect in the images that I created. So the question becomes: How do I get the correct resolution into the image? I start with bitmap data from a scanner. I'm doing this: CGDataProviderRef provider= CGDataProviderCreateWithData(NULL (UInt8*)data, bytesPerRow * le...

Crash-proofing Mac Cocoa application

In my Cocoa application I need to run a task that uses unstable unfixable code. It takes little input, works independently from the rest of the app, and generates thousands of ObjC objects as a result. How can I run the unstable part and let it crash without taking down whole application? Is it possible to fork() Cocoa application? How...

Why does this random number sometimes get set to -1?

Every now and again, the following comes out as -1 int randomIndex = random() % [directionsArray count] - 1; The init method for this class is where directionsArray is created and srand() is called. It looks like this - (id) initSprite { if ( ( self = [super initSprite] ) ) { speed = 1; directionsArray = [[NSArr...

NSImage -> PDFPage -> NSImage how do I mantain resolution?

I have a bunch of NSImages that I'm keeping in a PDFDocument, as PDFPages. When I insert the NSImage the first time, the size of the NSImage is in points (72 dpi), and the size of the (only) NSImageRep is in pixels (200 dpi). However, the NSImage that I get out of the PDFPage has 72 dpi for both image AND imagerep. How do I recover my...

How to embed app with log4cocoa?

Hi, Guys. I'm having some trouble to embed my application with the log4cocoa framework.I've embed frameworks in my application before with no trouble, but I cannot fix this one. First of all, this is my system out: dyld: Library not loaded: @loader_path/Frameworks/Log4Cocoa.framework/Versions/A/Log4Cocoa Referenced from: /Users/lean...

Bind to NSTreeController selectionIndexPaths

Hello, I want to bind to a NSTreeController's selectionIndexPaths programatically by doing the following (so that I can get a string a selection and display in a text view) [activePDFView bind:@"name" toObject:treeController withKeyPath:@"selectionIndexPaths.nodeName" options:options]; The tree controller is bound to a NSMut...

Is Cocoa animator proxy unable to handle 0.5 points?

I'm trying to move the origin of a custom view. If I directly set the new origin for the frame, everything is working fine as expected. [MyView setFrameOrigin:NSMakePoint(0.5, 0.5)]; If I try to animate the movement with the proxy animator. [[MyView animator] setFrameOrigin:NSMakePoint(0.5, 0.5)]; The new origin will be (1, 1) inst...

Cocoa performClick: in awakeFromNib not working

Hello, Im trying to call performClick: from awakeFromNib and its not working. I think its because it needs a sender and awakeFromNib has no sender. I have tried using nil,self and sender as the sender of performClick: but none seem to work. My code is - (void)awakeFromNib { [myButton performClick:sender]; } Can anyone think of a wor...

How can I remove the "blur" effect that Cocoa adds to transparent sheets?

By default, Cocoa adds a background blur effect to transparent and semitransparent modal sheets when they are applied to a window. I would like to disable the blur effect. How would I go about doing it? I have created a custom sheet (a subclass of NSWindow with a transparent background and some controls in it). I am able to display it u...

Achieving Mutability When Mixing Primitives and Cocoa Collections

Okay, I think I might be over-complicating this issue but I truly am stuck. Basically, I am trying to model a weight set, specifically an olympic weight set. So I have the bar which is 45 lbs, then I have 2 weights of 2.5 lbs, 4 of 5 lbs, and then 2 of 10, 25, 35, and 45 respectively. This makes a total of 300 lbs. bar = 45 lbs 2 of 2.5...

How can I disable Cocoa's default animation when displaying a modal sheet?

I would like to disable the animation that Cocoa performs when displaying a modal sheet. Apple's Sheet Programming Guide states: ... Other sheet behavior, such as the animation when it appears and is dismissed, is handled automatically by the Application Kit. But it doesn't provide any hints on how to disable this effect. I have ...

Sectioned NSTable view with NSArrayController

Hello, I am trying to create a sectioned NSTableView using bindings with an NSArrayController or multiple NSArrayControllers. Basically the data container is an array within an array. Do I bind an NSArrayController to the parent collection and then bind another NSArrayController to a child collection? Is this the right approach? Thank...

How can I implement the service locator pattern in Cocoa Touch across multiple projects?

This is a problem which has been bugging me for a while now. I'm still pretty new with some of these patterns so you'll have to forgive me (and correct me) if I use any of the terms incorrectly. My Methodology I've created a game engine. All of the objects in my game engine use inversion of control to get dependencies. These depend...

viewDidLoad in NSViewController ?

Hello, in iPhone I do UIViewController viewDidLoad and write some setup code to setup the view. But how can I do that in NSViewController? I've tried with loadView but it doesn't work... Maybe I do something wrong I don't know... PS: I've just started with OSX / iOS programming, so sorry if I ask something stupid :( ...

How to suppress compiler warnings en masse in Xcode.

Within several projects, I am using 3rd party code that produce more than a few compiler warnings. I obviously do not want to go through and modify code of actively updated 3rd party projects. This leaves me with a lot of unnecessary warnings that drown out warnings in MY code. I have used some compiler flags to suppress specific warni...

Retrieving CGImage from NSView.

Hi everybody, I am trying to create CGImage from NSTextField. I got some success in this. Still I cant get CGImage that consisting of only text. I mean to say that,every time capturing the textfield I am getting color of the background window along with it.(Looks like I am not getting alpha channel info) I tried following snippet fro...

Search For NSAttributedString with custom attribute and Remove it? How to?

I have a placeholder string, a space character, in an NSTextView that I want to remove at a future time. My strategy is to assign the NSAttributedString a custom attribute and perform a search on the [NSTextView string] removing it. So far, I haven't found a good way to do this, outside of going through [NSTextStorage attributeRuns]. ...

Drawing Image with CGImage?

I have my CGImageRef and i want to display it trough my NSView. But this code doesn't seem to work, i already have an CGImageRef from source path. Here's my code : - (void)drawRect:(NSRect)rect { NSString * thePath = [[NSBundle mainBundle] pathForResource: @"blue_pict" ofType: @"jp...

Are IBOutlet properties required to be nonatomic?

Getting up to speed with Cocoa iPhone/Mac development, I know the difference between atomic and nonatomic properties, and the performance difference with nonatomic, but every definition of IBOutlet properties I've seen specifies nonatomic, over the default atomic. I've not been able to find an explanation of whether this is a requirement...

Error when using MD5 algorithm

Hello helpful people! I'm trying to run this MD5 algorithm, which I found on this post on stackoverflow . But I keep on getting the following error: 2010-08-06 14:45:40.971 Intel[3195:a0f] -[TaskController md5:]: unrecognized selector sent to instance 0x108df0 2010-08-06 14:45:40.973 Intel[3195:a0f] *** Terminating app due to uncaugh...