Featured
-
To setup custom webroot for Apache in Maverick
Apache by default serves files from the Document r
by anirudh.rautela -
View Hidden Files and Folders In Macintosh
I just love to work on Mac but sometimes a small t
by anirudh.rautela
Tags
How to copy image in NSPasteBoard
To copy the image on NSPasteBoard following code can be used:
- (IBAction)paste:sender
{
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
NSArray *classArray = [NSArray arrayWithObject:[NSImage class]];
...
How to print an NSImage
The following code prints an image stored in a file:
-(void)print:(id)sender
{
NSImage *image = [[NSImage alloc]initWithContentsOfFile:[imageEdWindowController getImageLocation]];
[image scalesWhenResized];
NSImageView *	...
How to send email in mac os
Following code can be use to send email in mac os:
-(IBAction)sendEmailClicked:(id)sender
{
NSString *recipient;
NSString *mailsender;
NSString *mailsubject;
NSString *mailmessage;
recipient = [reciever stringValue];
...
How to convert NSImage to NSImageRep
You can convert NSImage to NSImageRep by using the following method:
- (NSImageRep*)bitmapImageRepresentation:(NSImage*)image
{
NSArray *ret =[image representations];
for(NSImageRep *rep in ret)
if([rep isKindOfClass:[NSIma...
How to convert NSImage to CIImage
To convert NSImage to CIImage following function can be used.
-(CIImage*)fromNSImage:(NSImage*)image
{
NSData * tiffData = [image TIFFRepresentation];
NSBitmapImageRep * bitmap;
bitmap = [NSBitmapImageRep imageRepWithData:tiff...
How to convert CIImage to NSImage
You can convert CIImage to NSImage by using the following function:
-(NSImage*)fromCIImage:(CIImage*)ciImage
{
NSCIImageRep *imageRep = [NSCIImageRep imageRepWithCIImage:ciImage];
NSImage *_image = [[NSImage alloc] initWithSize:[ima...
How to redirect console logs to a file
To redirect the log statements to a file instead of console call the following function at the start of function applicationDidFinishLaunching.
- (void)redirectConsoleLogToDocumentFolder
{
NSArray *paths = NSSearchPathForDirectoriesInDom...
Use of NSSharingServicePicker
The NSSharingServicePicker class presents a list of sharing services, so that the user can choose a service to share an item. When a service is chosen, the picker automatically executes it, which presents the sharing window.
+ (NSMenu *)menuFo...
NSSplitView delegate for controlling minimum and maximum sizes of views
NSSplitView have delegate methods where we control the minimum and maximum sizes of sections and which views expand or collapse by what amount.
Constraining the coordinates in the splitView:constrainMinCoordinate:ofSubviewAt: sets the minimum ...
NSSplitView delegate for priority based resizing
The default resizing mechanism in NSSplitView is proportional resizing in which if the NSSplitView changes size, each column resizes by an equal percent. But it is not successful in case where the columns in a split view are used to separate a si...
Cut image through code in mac os
Method to cut image in Objective-c/cocoa (OSX)
-(IBAction)cutItem:(id)sender
{
hasBeenDragged = NO;
NSImage *_sourceImage = [self image];
float width = selectedArea.size.width;
float height = selectedArea.size.height;
...
Crop image in mac os
If you want to crop the image without changing its quality in Objective-c/cocoa (OSX) then you can use the following method
-(IBAction)crop:(id)sender{
hasBeenDragged = NO;
NSImage *_sourceImage = [self image];
float width = sel...