cocoa

Cocoa - does CGDataProviderCopyData() actually copy the bytes? Or just the pointer?

I'm running that method in quick succession as fast as I can, and the faster the better, so obviously if CGDataProviderCopyData() is actually copying the data byte-for-byte, then I think there must be a faster way to directly access that data...it's just bytes in memory. Anyone know for sure if CGDataProviderCopyData() actually copies t...

Capture Backspace , is this a OK solution?

Hello, I having a hard time to capture the backspace button in a UITextView. I am trying to capture it in the method - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text I thought it was ok to do like this. if([text isEqualToString:@"\b") { // code ... } ...

Default Sorting with Core Data

This could well be a real stupid question, but I can't seem to sort my Core Data fetched results in the order they were saved to the persistent store. Effectively, I don't want to sort them at all, but omitting the sort descriptors from the fetch request gets me into all kinds of trouble. Is what I'm trying to achieve here possible, or...

Retrieve file size from web server

Looking for a way to retrieve a file size from a web server using cocoa/foundation. I know one can use NSURLconnection which will return NSURLResponse that contains the file size. Is there any other way to get the size. I'm looking for a synchronous way of doing it so when i do [myClass getsize] the size is returned. Thanks ...

Basic problems (type inference or something else?) in Objective-C/Cocoa.

Hi, Apologies for how basic these questions are to some. Just started learning Cocoa, working through Hillegass' book, and am trying to write my first program (a GUI Cocoa app that counts the number of characters in a string). I tried this: NSString *string = [textField stringValue]; NSUInteger *stringLength = [string length]; NSStri...

How do I load PersistentDocuments into the same window

I want to open NSPersistentDocuments and load them into the same window one at a time. I'm almost there but missing some steps. Hopefully someone can help me. I have a few saved documents on the hard drive. On launch my app opens to an untitled NSPersistentDocument and creates a separate NSWindowController. When I press the button t...

Circular NSSlider with stop (non-continuous)

I am not sure how to phrase this better as a title but I need to make an NSSlider that functions as a normal volume knob. At the moment it will spin around as many times as I hold the mouse down and move it around the control. I need it to stop at the "0" position and the "100" position, I cannot have it jumping from 0 to 100 when I dr...

How to delete all objects for a given entity from the ManagedObjectContext

I don't want to use the reset method for my ManagedObjectContext. I only need to remove all of the objects for a specific entity, but I don't see any methods for doing this. Selecting all of the objects for a specific entity and looping over each and deleting them works, but it's very slow. ...

Cocoa accessibility API, can I click a window in the background without activating it?

I've been searching forever for a solution to this, so I thought I'd seek out the brainpower of greater minds than mine. I'm developing a Cocoa app that uses the Accessibility API to manipulate another program (it's a hotkey app). The app I'm controlling typically has multiple windows open, with some hidden behind others. What I would...

Lego-Style Cocoa Workflow Application

Hi, I currently have to develop a system very similar to MIT's Scratch's UI. In case you don't know it, here a screenshot: http://kidconfidence.com/blogs/wp-content/uploads/2007/10/scratch1.png Basically you have bricks in the library on the left you can drop into the window on the right side. The problem I have is that I'm new to Co...

Array of Objects in Core Data Entity?

I've got two entities, one named exercise and the other named workout. I would like to store several different exercises in each workout object. What is the correct logic here? Create an array of exercises in each workout? ...

NSStream sockets missing data

I am trying to pull some sample data from FreeDB as a proof of concept, but I am having a tough time retrieving all of the data off the incoming stream (I am only getting the last bits for the final query listed here (if handshakeCode = 3) I think this may be something with the threading on the main runloop, but I am not sure. Odd thing...

Should i use a C function or Obj-C Method?

I'm about to create a function which adds two NSDateComponents together is there any advantage to putting this in a C style function or should it go in a Obj-C method? Is there ever a reason to use one rather then the other or should I always stick to Obj-C? BTW: Not that it makes any difference I'm sure but this is for an app on the i...

Can't get Jacobi algorithm to work in Objective-C

Hi, For some reason, I can't get this program to work. I've had other CS majors look at it and they can't figure it out either. This program performs the Jacobi algorithm (you can see step-by-step instructions and a MATLAB implementation here). BTW, it's different from the Wikipedia article of the same name. Since NSArray is one-dimen...

Debugging runtime error "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'"

I'm going through the Beginning iPhone Development book & stuck in chapter 9. I've spent a few hours trying to debug this error w/o avail: 2010-05-01 19:27:51.361 Nav2[4113:20b] *** Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit/UIKit-984.38/UITableView.m:4709 2010-05-01 19:27:51....

Detect when screensaver activates with Cocoa

Is there a way to trigger an action when the Mac OS X screensaver activates or when it goes to sleep (preferably using cocoa)? ...

NSTask or NSThread?

I have some code that is attached to an NSTimer. Around 5 times every second, it interacts with another application (by emulating keystrokes) and when appropriate spits out an NSNotification, that is handled by another piece of code. While the timer code is running, the UI is unresponsive, so I can't include a 'stop' button that halts ...

NSKeyedUnarchiver chokes when trying to unarchive more than one object

We've got a custom matrix class, and we're attempting to archive and unarchive an NSArray containing four of them. The first seems to get unarchived fine (we can see that initWithCoder is called once), but then the program simply hangs, using 100% CPU. It doesn't continue or output any errors. These are the relevant methods from the matr...

Sporadic EXC_BAD_INSTRUCTION (SIGILL) when in 64 bit mode

For some reason for a low-number of users (say 1 in a few hundred) the application seem to crash when run in 64bit mode on a Snow Leopard 10.6.3 I've attached the stack traces. The crashed seem to be random in com.apple.AppKit at random locations and random moments. Anyone else had any experiences? Using GCC compiler of Xcode 3.2.2 Cr...

quartz composer view output: How can I get immediately the new values of outputs, if they change?

Hello, I created a cocoa program with a quartz composer view. I can get the output values with: [qcView valueForOutputKey:@"Output"] But how can I get immediately the new values of outputs, if they change? ...