cocoa

Mac OS X: Best way to implement a card game GUI

Hi, I've started programming on Mac OS X in Objective-C and decided to create a little card game. At first I create a command line version. If everything works fine I would like to implement a GUI: Nothing big, just a green window with cards which can be dragged and dropped. Since I don't have any idea about how to do this: What can I ...

Clearing the alpha channel of an NSImage

It can be done by mallocing a temporary bitmap with 32bits per pixel and then clearing the alpha component with a for loop and and finally turn it back into a NSImage again. I suspect is can be done in a simpler way using a clever combination of NSColor and NSCompositingOperation. Or perhaps the image needs to be composited with itsel...

Writing YUV data into a CGContext

How can I write a YUV frame data into a CGContext? ...

Is there a best way to size an NSImage to a maximum filesize?

Here's what I've got so far: NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData: [file.image TIFFRepresentation]]; // Resize image to 200x200 CGFloat maxSize = 200.0; NSSize imageSize = imageRep.size; if (imageSize.height>maxSize || imageSize.width>maxSize) { // Find the aspect ratio CGFloat aspectRatio = imag...

How to make main window visible in Cocoa?

This is kind of a followup to this question. I have the following code: - (BOOL)applicationShouldHandleReopen:(NSApplication *)app hasVisibleWindows:(BOOL)flag { NSLog(@"Has visible windows: %d, main window visible: %d", flag, [[app mainWindow] isVisible]); if (!flag) { // I need to make mainWindow visible again here. HO...

Removing an Observer.

In a NSManagedObject Sub Class I have the code … - (void) awakeFromInsert { [self addObserver:[NSApp delegate] forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil]; } Which adds my App Delegate as an Observer, what I want to do now is from inside my App Delegate, I want to remove itself as an Observer for my NSManag...

Objective-C: instance variables out of scope in debugger

I have a superclass and a subclass, both of which define instance variables. Rough outline of superclass: /* GenericClass.h */ @interface GenericClass : NSObject { /* some variables */ } @end /* GenericClass.m */ @implementation GenericClass /* ... */ @end Outline of subclass: /* SpecificClass.h */ #import "GenericClass.h" ...

Objective C - NSImageView, NSImage, NSBitmapImage rep object lifecycle?

I've built a video viewer that is a Safari plugin that displays video from networked devices. The viewer reads bitmap images, prepares them, and sets them on the NSImageView object as follows: NSBitmapImage *bmImg = [[NSBitmapImage alloc] initWithBitmapDataPlanes: . . .] NSImage *img = [[NSImage alloc] init]; [img addRepresentation:bmI...

Works with number of string contained in NSArray

Hi, I need to pick string valur from an NSMutableArray then save it into a plist. I've builded an NSMutableArray to display infos in table View. Maximum allowed index is 8. (paste just two in example) The problem if the String doesn't exist, I get the following error: sDict is a dictionary for saving datas to a property list file. th...

How to declare a string in Objective-c?

How do I declare a simple string "test" to a variable? ...

How do I create a CGImage with RGB data?

Can anyone show me a clear example of how to use CGImageRef CGImageCreate ( size_t width, size_t height, size_t bitsPerComponent, size_t bitsPerPixel, size_t bytesPerRow, CGColorSpaceRef colorspace, CGBitmapInfo bitmapInfo, CGDataProviderRef provider, const CGFloat decode[], bool shouldInterpolate, CGCo...

How can I decrypt blowfish encrypted string without using OpenSSL in Mac OS 10.5/10.6

My application is currently using SSCrypto.framework to decrypt a string encrypted with Blowfish. SSCrypto utilizes OpenSSL which is a new problem for me. Using the 10.6 base SDK while targeting 10.5 doesn't seem to work. The issue is explained in this Apple Mailing List thread: http://lists.apple.com/archives/Cocoa-dev/2009/Aug/msg01737...

Supporting limited number of currencies in Cocoa(Touch)

Early versions of our app will only support a limited number of currencies. If a user should try to use our app with an unsupported currencyCode then I'd like to set the currencyCode to one that is supported. I'm getting myself confused bouncing between NSNumberFormatters, currencyCodes, NSLocales, etc... Currently I test the NSNumberF...

Time remaining from NSProgressIndicator

Hi all, I am developing an application in cocoa,I need to calculate the time remaining from NSProgressIndicator .Is that posiible??? Thanks in advance........ ...

Is there a way to view the undo stack?

I'm learning about undo, and I'd like a way to peek into the undo objects (NSInvocations) in the undoManager so I can see what's going on. I couldn't see anything like this in the docs, but maybe someone knows a way. Thanks. ...

Beginners Cocoa Binding Question

I just started with Cocoa Binding and I am working on my first application. Many samples and books use the NSArrayController but since I only want to bind a single Object and his properties to some Textfields I used the NSObjectController. I also don't have a document based application. My application is a simple one-window application....

How do you use groups in XCode?

I started using groups in Xcode the same way I use packages in Java or namespaces in C++, even though groups have no effect on the language. Then I discovered Smart Groups and realised that it's sort of pointless to have my code neatly organised in "folders". Do you use groups? If so, how and why? ...

Why is bitmapImageRepForCachingDisplayInRect: creating an empty image?

I have a very simple bit of code that is supposed to capture the bitmap of a view. This used to work in Leopard, but seems horribly broken in Snow Leopard. Here is the code, responding to a button press on the window: - (IBAction)snapshot:(id)sender { NSView* view = [[sender window] contentView]; NSBitmapImageRep* bitmap = [view b...

How to Prevent or Compensate For Scaling Transforms of Core Graphic Paths?

I am attempting to create a "marching ants" (an animated dashed line) selection indicator around UIView that contains a UIImageView subview. Drawing the dashed line around the perimeter of the UIView is trivial using core graphics: -(void) drawSelectedMarquee{ CGContextRef c=UIGraphicsGetCurrentContext(); CGContextSetStrokeColorW...

Pantomime and Mail Frameworks? - Cocoa

Does the Pantomime Framework work for 10.5 or 10.6? Because when I look at the build error I get when compiling it says, it couldn't find the 10.4 sdk. If not, then does anyone know any other framework that works really well with 10.5 or 10.6, with an example? ...