Converting an NSImage to grayscale

Create NSValue object that holds Integer value

An NSValue object is a simple container for a single C or Objective-C data item. It can hold any of the scalar types such as int, float, and char, as well as pointers, structures, and object ids. The purpose of this class is to allow items of such data types to be added to collections such as instances of NSArray and NSSet, which require their elements to be objects. NSValue objects are always immutable.

    NSValue* valObj;
    int theInt = 123;
    const void *myVal = &theInt;
    void *valPtr;
    valObj = [NSValue value:myVal withObjCType:@encode(int*)];

    [valObj getValue:&valPtr];

Blogged with the Flock Browser

Encryption for cocoa, cocoa touch

Cocoa Views in Carbon Windows


Cocoa provides views that are either not currently available in HIToolbox or are available without full support. These include views such as WebView, PDFView, QTMovieView, and NSTokenField. In addition, the Cocoa and Carbon control hierarchies are incompatible, so it has been difficult or impossible to have views from both frameworks embedded within the same window.

A new type of HIView called HICocoaView provides a general solution to these problems. You can embed a Cocoa view (any subclass of NSView) inside the HIView control hierarchy of a Carbon window. This is accomplished by associating the Cocoa view with a Carbon wrapper view called HICocoaView, a subclass of HIView. You can use standard HIView functions to manipulate the wrapper view, and you can use Cocoa methods to manipulate the associated Cocoa view. HICocoaView is supported only in compositing windows.

HICocoaView is available in Mac OS X v10.5 and later. For more information, see Carbon-Cocoa Integration Guide.

Blogged with the Flock Browser

CGRect to NSRect

NSRect nsRect = *(NSRect *)&cgRect;

Blogged with Flock

Tags: , ,