cocoa

How can I retrieve the HTML to be loaded into a WebView (or WebFrame) from a local persistent store?

So, I have a bunch of HTML is being stored in a SQLite database, and they link back and forth amongst themselves. When a user clicks to follow a link, that request needs to be serviced by pulling the appropriate HTML out of the database. This could result in needing to load images, which are also being stored in the database (this is a f...

In Cocoa, what is the best way to change the cursor when hovering over a circular view?

What I want to do I have a circular custom NSView subclass, and I want to change the appearance of the cursor when the mouse is hovering over the circular portions of the view, but not when over the portions of the view's rectangle that fall outside the circle. Here's an illustration. I would have inlined it with an image tag, but I'm ...

Is there an API to do per-pixel Alpha Blend on GTK and OSX ?

I want to draw transparent windows (with alpha channel) on Linux (GTK) and OSX. Is there an API to do that ? Note that I don't want to set a global transparency, the alpha level should be set per pixel. I'm looking for the same kind of API than the UpdateLayeredWindow function on Windows, as in this example: Per Pixel Alpha Blend. ...

Defining and executing simple AppleScript commands in a Cocoa app

I'm trying to add some scripting functionality to a Cocoa app that I've written. I've created an sdef (Scripting Definition File) for my project. So far I have been successful in accessing object children (elements) with AppleScript but I cannot for the life of me figure out how to call methods (commands). Here is my sdef file. <suite ...

Better way to move NSView bounds with player?

Currently writing a roguelike to learn more about Objective-C/Cocoa. I'm really enjoying it so far and I've learned tons. This code moves the origin of the view's bounds, so that it follows the player as he moves. The code works perfect, I was just asking if there was a better way than using four for's. I've also seen in some cases th...

How do you get the int and modulo (mod) of division with an NSDecimalNumber

I am confused by NSDecimalNumber and its "behaviors". I have an NSDecimalNumber that represents a dollar value, say $37.50. I'd like to find out how many times say 5.0 goes into that number and then know what's left over. I can get the straight division and get 7.50 but I want 7 mod 2.50. I could convert to an integer but need to save th...

How do I draw a shape in Quartz Composer for every element in an NSArray?

I have an XML file that I have parsed and have put the information I want into several NSArray objects. I want to be able to draw them in a QuartzView (anything better?) to visualize the data. The arrays should all hypothetically contain the same amount of info. I want one array to represent the x axis and another the y. It took long...

Altering the style of an NSSearchField.

I am wondering how I would change the look of an NSSearchField, I am pretty sure it would mean sub-classing NSSearchField, but the bit I don't know how to do is code it to make it the way I want it to look. Below you can see the way I want it to look and how it looks currently. How would I make it look like this (on the left) by usin...

Simulating a click for NSCollectionView

In an attempt to create drag and drop between two NSCollectionViews in the same app i've made the view that holds the collection views responsible for all the mouse clicks. It then checks what the mouse actually hits, etc. One problem I'm having though, is trying to get the NSCollectionView to handle single clicks properly (i.e. if the s...

Core Data simple relationship in code

Hi, I am a cocoa newbie trying to create an iPhone app including Core Data. My problem is this: I have a little app running now with a single entity called Playlist that I display in a table view and can add and delete entries in. I have these in my PlayerAppDelegate: playlistManagedObjectModel playlistListManagedObjectContext play...

Number of days in the current month using iPhone SDK?

A fairly straight forward question, I am trying to figure out how I can get the current number of days in the current month using NSDate or something similar in Cocoa touch. Thanks. ...

Where should I keep Core Data fetches and convenience methods?

I've got a number of convenience methods that perform fetches for my Core Data entities. For example, a method that returns currently-active activities, or a time interval between two completed activities, or a default client if there is one. I also have convenience methods to initialize and add entities with various attributes. I have ...

How to detect when a CATiledLayer has finished drawing all tiles

I need to detect when a CATiledLayer has finished drawing. I tried subclassing and overriding -(void)display to set/clear a flag, but it seems that tile drawing is happening in a different thread (display just returns and then seconds later, the layer is finished drawing) ...

What is the best way to store document specific settings in a Core Data Document?

I'm using a NSPersistantDocument backed by Core Data in my application. Each document has a number of settings that are only relevant to that document. For example the document needs to hold the unique ID of an Address Book Group, to update it at a later date. The way I'm thinking of approaching this is to have another model, DocumentS...

How do I turn an NSMutableData into an image in a view?

I downloaded a .jpg file from the Internet with this code: NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://cvcl.mit.edu/hybrid/cat2.jpg"]]; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; receivedData=[[NSMutableData data] retain]; // etc etc Everyt...

Trouble with NSDecimalNumber's decimalNumberByDividingBy:withBehavior:

I always seem to run into trouble with NSDecimalNumber! Today, I get this error: "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFNumber decimalNumberByDividingBy:withBehavior:]: unrecognized selector sent to instance 0xd1fb10'" Here is the source of the error: - (void)setUpInstance { ...

NSString Retain Problems

I am having some problems with NSString retaining. My problem is that on the second function (runItem) it doesn't seem to picking up on the value of the item1. No matter what I set it to, it seems that it is just set to nil. I am programming for Cocoa (desktop, versus iPhone), and I haven't had this type of problem with NSString befor...

Filtering a NSOutlineView/NSTreeController.

How would I use a search box to filter a NSOutlineView/NSTreeController? I know it would have something to do with bindings and a predicate. But not specificaly how to. Could someone take me through the steps of filtering an NSOutlineView/NSTreeController? ...

The correct NSPredicate format for one-to-many relationship in Core Data

Hello, I have a managed object model A and B with one-to-many relationship. For this particular task, I want to retrieve all A objects which has a relation to B with a property matches to "string". I had tried @"ALL bObjects.bProperty MATCHES 'string'", and it caused an objc_exception_throw in: [NSSQLGenerator generateSQLStatementFor...

Can an objective-C NSThread access global variables?

Ok, basically I have a run loop going in my application every second or two, while at the same time I have another thread going that is looping through the listenForPackets method; broadcastMessage is only initiated when another action method takes place. The important part of this question is that when the listener thread is running sep...