cocoa

Scrolling to range in UITextView

I have a UITextView with text in it, and I want to be able to scroll it such that a given NSRange of the text is at the top of the view. Using scrollRangeToVisible: does not work: it will scroll the range such that it is somewhere in the view, not necessarily where I want it to be. How can I scroll such that this specific NSRange of text...

How to block until certain notification is posted in Cocoa?

What's the best way to sleep/wait until certain notification is posted? I've got class with asynchronous API that gets data from NSNotification (notification comes from Cocoa, I can't avoid it) and I need to unit test it. So far I've figured out semi-busy wait: [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow...

XCode Linking build error

This one is new to me. Not even sure what RootViewController.o is? though this project does have a .m & .h. Building for Simulator 3.0. Cleaned before build (Shift-⌘-K). Recently added some classes from another project that also had a RootViewController...but I didn't transfer old one over. Haven't built since. This could be part of th...

Purpose of a static library

I want to create an application core that connects to a webservice, downloads the data, parses it and then returns it to a view controller. This core would ideally handle requests from multiple controllers and abstract away a lot of repetitive code. Also, I want to potentially use this core for a mac os x application. Would these tasks...

CoreData Memory management Problem

I'm using Coredata and have a Data Model with the following toMany relationships: Rooms.isUsedBy -> Class many classes use a Room Class.hasStudents -> Students many Students are in a Class Given the Room I want to get all of the students that use the room. Here is the simplified code: -(void) studentsinRoom:(Room*)aRoom { ...

Which GUI element does iCal use for calendar view?

I’m writing a simple iCal-like app in Cocoa that I’d like to resemble the main view of iCal. Does anyone know which GUI element (i.e. NSWhatever) was used to create the Month-view (this thing: http://skitch.com/edwardog/b38ba/ical)? Thanks! PS – A hint at figuring this sort of thing out for myself would also be well appreciated; I’ve ...

EXC_BAD_ACCESS with Objective-C Properties

In my iPhone application, I have the following line in a constructor: self.myVar = myVar_in; where myVar is a property and myVar_in is a parameter passed to the constructor. When I run the code, I get an EXC_BAD_ACCESS error on this line. However, when I replace the line with: [myVar release]; [myVar_in retain]; myVar = myVar_in; t...

Cocoa: Checks required for multiple asynchronous NSURLConnections using same delegate functions?

This is with reference to the StackOverflow question Managing multiple asynchronous NSURLConnection connections I have multiple asynchronous HTTP requests being made at the same time. All these use the same NSURLConnection delegate functions. (The receivedData object is different for each connection as specified in the other question ab...

Detecting when an NSView is dealloc'ed

Is there any way to detect when an NSView will be dealloc'ed? The reason is, I have some simple delegates (such as an NSTextField delegate that handles -control:textView:doCommandBySelector: to allow the return/tab keys to be entered). I'd like to just stick this delegate object in the nib, wire up the NSTextField's delegate connection...

Well written Open Source Cocoa Apps to learn from

Hey, I'm learning Cocoa and while I get comfortable with Objective-C and the concepts around it, I sometimes struggle applying the theory (like MVC) in praxis. Apple's documentation often gives me aha moments, but it would be cool to have a well written Cocoa App as a reference. So, do you know a very well written Cocoa App with public...

Trouble with Float in Objective-c [SOLVED]

I've a small problem and I can't find a solution! My code is (this is only a sample code, but my original code do something like this): float x = [@"2.45" floatValue]; for(int i=0; i<100; i++) x += 0.22; NSLog(@"%f", x); the output is 52.450001 and not 52.450000 ! I don't know because this happens! Thanks for any help! ~SO...

how to search the file in the next level of the mac root ?

I want to search a file and get it in the mac root . I used the subpathsAtPath: of NSFileManager and put the root path "/", but I found that this func searched so deeply and took a long time. I hand known that that the file I want to find in the the next level of root , what func I can used , thanks a lot! ...

Copying an NSArray with mutable copies of the original elements

I am creating an array of dictionaries in a class. I want to return a copy of that array to any other object that asks for it. This copy that is passed to other objects needs to be modified without modifying the original. So I am using the following in a getter method of my class that holds the "master" array: [[NSMutableArray alloc] i...

SetHidden not working

Hi all, I am developing an application in cocoa.I need to hide a progress bar placed in an NSView and show an NSTextfield in that place .I used the following cod [progressbar setHidden:TRUE] [textfield setHidden:FALSE]; But this code snippet is not working. Is that a bug.??I used to hide the same code to hide certain other text fields i...

DTrace on Leopard: No probes specified, even when I specify probes

% sudo dtrace -p 2446 'objc$target:NSObject:-init:entry { trace(); }' dtrace: no probes specified The manpage suggests that this is the correct format with which to specify a probe on an Objective-C method. I tried -Z, but (unsurprisingly) that just didn't print anything. [Added] It's not even specific to Objective-C probes. I tried i...

CoreAnimation jerky with large window

I have a very simple CA demo. It creates a layer with content from an image file, and displays that image. When you click in the window, it uses implicit animation to smoothly move the image to the mouse point. This works fine, runs with perfect smoothness. But, as the window gets larger, the smoothness gets less. It's acceptable below a...

Why does DTrace give me invalid-address errors some times and not others?

My program: typedef struct objc_class { struct objc_class *isa; struct objc_class *super_class; char *name; long version; long info; long instance_size; void *ivars; void *methodLists; void *cache; void *protocols; } *Class; struct objc_object { Class isa; }; /* Code to extract the class name from arg0 based on a snippet by ...

Deleting A Row From An Outline View.

I have an outline view and a button. I want the button to remove the selected row in the outline view. I have bidden the Outline View's Selection Index Paths to the Tree Controller ,connected the button to the Tree Controller's 'remove:' connection and bidden the button to the 'canRemove:' property of the Tree Controller. But once I have...

NSZombies are eating my app's brain!

I've got a retain/release problem. My View is pretty complicated so I've set NSZombieEnabled to YES and am trying to locate which, exactly, object is causing me grief. To speed this process along I'm wondering if there hints or tricks to tracking the Zombies back to the grave they dug their way out of (sorry, had to) or, back to the obje...

NSStatusItem to be always left?

Hi, I'm working on an app that displays certain information on the status menu, and I was wondering if there's any Cocoa API that can make my NSStatusItem always placed on the most-left, no matter when it's started or if other apps are started after it. NSStatusBar *bar = [NSStatusBar systemStatusBar]; barItem = [[bar statusItemWithLen...