cocoa

Prevent an instance of NSView from receiving mouse events

Hi, I have an NSView in a window with core animation layer turned on. I use this view to display images with animation from time to time. I need the entire view to be the back layer not only the images. Behind this view which I call AnimationBaseView are other views which the user interacts to. Everything is ok except the AnimationBase...

Bonjour to JmDNS from iOS: What's the name?

I'm sure I'm just a few letters away from getting this to work, but maybe not... On the server-side, I've got this (Java); ServiceInfo info = ServiceInfo.create("_mjdj._tcp.local.", "foo", 1268, 0, 0, "path=index.html"); jmdns.registerService(info); This works perfectly with my Java client or a Bonjour Browser (service shows as "_mjd...

Text rendering looks jagged when converting PDF to image using Cocoa on Leopard but not Snow Leopard

Hello, I have a program that composites the pages of a PDF into a single image with each page stacked on top of each the previous one. The program works fine, but the font rendering quality is much lower when run from anything but a Snow Leopard system. In Leopard, the text looks jagged and not antialiased properly. Does anyone know ...

NSString to 64bit integer converstion on iPhone

Hi! I am struggling with very simple thing: I receive some ids by http request as a string. I know they represent 64bit integer id numbers. How can I convert them to the 64 bit Integers (NSNumber or NSInteger)? Functions like: [nsstring integerValue], [nsstring intValue] seems to be 32bit limited (max value:2147483647). Any Hints? ...

How to read data from NSFileHandle line by line?

I have a text file having data as given e.g. PUFGUjVRallYZDNaazFtVjVObU1zWm5ZcUJUYU5ORk4zbGthNHNDVUdSMlFVQmpSVEoxUUNSallYaFhkanBITXBGR1NTQnpZRTltZE1OalVzSkdXQ0Z6WXR0V2RpTmpTdXgwTWs5V1lZSkZiWjFXT29OV2JSVlhaSTUwYUpwR040UUZXTzVHVXFoWFVRcFdWNHdVTUJ0Q1VHSmxXVlJVTlJCMVE1VTFWV PUFGUjVRallYZDNaazFtVjVObU1zWm5ZcUJUYU5ORk4zbGthNHNDVUdSMlFVQmpSV...

Objective-C Class Prefixes

What's your preference with naming ObjC classes? I'm a little uncertain what would be the most reasonable approach on this so it would be nice to hear some other opinions. Apple recommends prefixing cocoa classes, because ObjC doesn't support namespaces. The Google ObjC styleguide (which i mostly aim for) does away with them, unless you...

How to remove a SubView from a NSSplitView in cocoa?

I'm loading two different views with this IBActions - (IBAction)showFirstView:(id)sender{ theDetailViewController = [DetailViewController new]; [theDetailViewController initWithNibName:@"DetailView" bundle:nil]; NSView *splitRightView = [[theSplitView subviews] objectAtIndex:1]; NSView *aDetailView = [theDetailViewCont...

Key-value coding for mutable collections & atomic accessors

My question, in brief: Is there any way to make mutable collection KVO accessors thread-safe with the same lock that the @synthesized methods are locked? Explanation: I have a controller class which contains a collection (NSMutableArray) of Post objects. These objects are downloaded from a website, and thus the collection changes from t...

Cocoa send background window to front

At the bottom of this post I included an example project that has my code in it. I have a Cocoa Application that uses a main default window, and another window nib I created. When the program starts, I want it to load the window nib and show it in front of the default 'MainMenu' nib window. How can I do this? I've tried the following co...

Cannot get Cocoa notifications to work

Settting up the observer code: NSNotificationCenter *defaultCenter = [[NSWorkspace sharedWorkspace] notificationCenter]; [defaultCenter addObserver:self selector:@selector(updateLog:) name:@"Update Log" object:nil]; Sending the notification code: [[NSNotificationCenter defaultCenter] postNotificationName:@"Update Log" object:se...

Memory about lazy loading

I am reading tutorial book now. When I see an example, I get some confused. The following codes show a way for lazy loading. Does this motivations array be released after instance deallocated ? or will it occupy this memory block until application terminates. + (NSArray *)motivations { static NSArray *motivations = nil; if (!mot...

Multiple window application

I am looking for a cocoa example that illustrates how to create a multi-window app. Two windows, two nibs. Clicking a button in one window shows another window. How can I do this? ...

Is it possible to know what text is displaying nearby the mouse?

I am just planning to implement some features like "Look up in Dictionary" when the mouse hovers over some text/words on the screen on the Mac OS X platform. How can I get the displaying text/words nearby the mouse on the screen, even if they're not in my own application. What I can do is: Using WorkSpace to know what applications ar...

How to store a NSUInteger using NSCoding?

How do I store a NSUInteger using the NSCoding protocol, given that there is no method on NSCoder like -encodeUnsignedInteger:(NSUInteger)anInt forKey:(NSString *)aKey like there is for NSInteger? The following works, but is this the best way to do this? This does needlessly create objects. @interface MYObject : NSObject <NSCoding> { ...

Cocoa: Custom Controller Key for NSArrayController

Is it possible to create a custom controller key for an NSArrayController? There are keys for "arrangedObjects", "selection" etc... Is it possible to implement your own? I can't seem to find any info on this anywhere. My reason for wanting to do this (besides it seeming like a useful thing to be able to do) is: I have Entity "Car", wit...

Can't put a NSString into a NSMutableArray and store it in NSUserDefaults

new problem: I am receiving this error: '-[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable object' In the ViewDidLoad I initialized my array: id object = [[NSUserDefaults standardUserDefaults] objectForKey:@"array"]; if (object) { locationArray = object; NSLog(@"retrieved", object); ...

Using Spotlight in Cocoa

Can I use the Spotlight APIs (they exist, right?) in Cocoa to determine if Spotlight (in the upper-right corner) would match a given filePath with a given string? In other words, given a filePath such as "/Users/enchilada/Desktop/MapOfUSA.pdf", and a string such as "Virginia", how would I tell if Spotlight would show this file when "Vir...

NSCalendar problem with BC era

Greetings, Recently I faced a big problem (as it seems to me) with NSCalendar class. In my task I need to work with a large time periods starting from 4000BC to 2000AD (Gregorian calendar). In some place I was forced to increment some NSDate by 100 year interval. When incrementing the years in AD timeline (0->...) everything worked fin...

Change PDF font colour with PDFKit

Hello, Is there a way to render the font of a PDF document in a different colour using the PDFKit library in Cocoa? If not, is there another technology that I should explore? Thanks. ...

setBackgroundColor covers element

I have an NSWindow, and I'm using this code to add a bottom-metal-bar at the bottom. [MyWindow setContentBorderThickness:40.0 forEdge:NSMinYEdge]; That works fine. But, once I use this: [MyWindow setBackgroundColor: [NSColor redColor]]; The red covers the bar at the bottom. The bar shows correctly without the background color. ...