cocoa

Removing an Object with A Certain Title from an NSTreeController.

I am wondering how I could delete an object depending on it's title for the CoreData 'name' property I have. To Add an Object I use this code: NSManagedObjectContext *moc = [self managedObjectContext]; JGManagedObject *theParent = [NSEntityDescription insertNewObjectForEntityForName:@"projects" in...

How to access / embed Finder functionality?

Is it possible to embed Finder functionality in a cocoa app, now that Finder is itself cocoa (assuming the app were to function only in snow leopard)? What I mean is to have a file browser pane as part of the app, actually browsing the file system itself (to edit in another pane), but without writing all the functionality of the Finder....

Warning in ITunesFinder example (Apress - Learning Obj-C)

When I compile the code below I get the following warning: Incompatible type sending "ITunesFinder *" expected "id"? I am only just starting out and to be truthful am a little confused by this example. I would be interested to know if there is a way to write this example without using the delegate class? I am also a little confused by ...

Two Digit Years with NSDateFormatter not working

I have a 10.4 style date formatter applied to an NSTextFieldCell. I call setTwoDigitStartDate: (tried with both the epoch date and the "reference" date) but when I type in a date with a two digit year it sets the year to 0009 instead of 2009. Header: IBOutlet NSTextFieldCell *transactionDateField; // outlet *IS* set correctly in IB I...

Getting type encodings for method signatures in Cocoa/Objective-C?

I need to construct an arbitrary NSMethodSignature with "signatureWithObjCTypes:" in Cocoa without having an object that I can ask for a signature with "methodSignatureForSelector:". For this, I need the method encoding, which e.g. is c12@0:4@8 for (BOOL) isEqual: (id) object I tried @encode(...) to obtain a type encoding, but th...

Cocoa-Touch: NSDateComponents crashes on releasing a fresh instance

I have: NSDate *d = [[NSDate alloc] init]; unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit; NSDateComponents *dc = [calendar components:unitFlags fromDate:d]; // doing something with dc.day, dc.month, dc.year [dc release]; [d release]; I've tried removing the "doing something.. part", just did a get a...

How to invert the co-ordinate system in NSOpenGLView

I have create my own NSOpenGLView class, right now the data that i want to displayed with an inverted co-ordinate system. The origin starts at the bottom-left corner. I would like to change it so that the co-ordinate starts at the top-left corner. How should I inverted the view/setup a new co-ordinate system. ...

What does < > mean / represent in a class interface?

I am sure I have read this somewhere, Can anyone tell me what the < > represent in the following interface? @interface GameFinder : NSObject <NSNetServiceBrowserDelegate> @end is NSObject adopting <NSNetServiceBrowserDelegate> ? EDIT One thing that is confusing me ... in the example I have.The interface shows NSNetServiceBrowserDel...

Sending an event to an NSControl underneath another NSControl if it does not handle it

I have multiple superposed controls which can handle a mouse click under certain conditions. What I want to be able to do is: The top control receives the mouseDown: event. The top control decides if it handles the mouseDown: event. If it does, do something and prevent other controls from receiving the mouseDown: event. If it does not,...

Cocoa-Touch: memory management

I'm customizing a UIPickerView's rows, so I'm implementing the viewForRow method in it's delegate as follows: - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { if (view) { return view; } else { NSString *s = [datePickerValues...

Instruments showing false leak?

I am not sure why Instruments is showing the following code as leaking 128 bytes on the UILabel initWithFrame line: self.navigationItem.leftBarButtonItem = self.editButtonItem; UILabel *tmp = [[UILabel alloc] initWithFrame:CGRectMake(25, 100, 275, 100)]; self.emptyMsg = tmp; [tmp release]; Note that in this classes is releasing the e...

Getting input objects in Cocoa...What's better style?

I have a factory-type class that creates its products based on the traits of another object. This means that I need a reference to the input object somewhere. I am planning to either: A) Define the input object as a property and set it in a custom init method. So the factory's owner calls "initWithObject:", then calls "createProduct"...

Telling IKImageBrowserView not to schedule preloading

For our rewrite of the open-source iMedia framework project (in use currently by dozens of developers), we are switching to IKImageBrowserView, and having a troubling time with caching. It appears that IKImageBrowserView likes to preload/prefetch a cache of images, as a low-priority background task, as many not-yet-visible items that it...

NSMutableDictionary lookup based on object's address or value when dealing with NSNumber?

If you store NSNumber* as a key to NSMutableDictionary, does it do the lookup later based on the key's address or stored value? It seems that if I store NSNumber in two dictionaries with the value from one serving as the key to the other, sometimes, the key isn't found in the 2nd dictionary even though I'm certain it's in there. What I'...

How does it know which method to call?

This is a follow-on from a previous question, in the implementation, I have two methods, one which gets called when a particular service is found and the other when it vanishes. This might be a dumb question, but apart from the NSLog lines they are identical, what dictates which gets called? // INTERFACE @interface ITunesFinder : NSObje...

Searching Through a TextFile - Cocoa

How would I type up a code that searches through a text file from a given directory. I want the search word to be "password123" and if it contains that, then it will proceed onto the next step, if not it will give an error message. ...

Add an item to the Finder/Save dialog sidebar

I'm working on a script where a user logs into a guest account on OS and is prompted for their network credentials in order to mount their network home folder (while they benefit from working on a local user folder). As the guest folder is deleted when users log out, I want to discourage them from saving anything there. I would like ...

NSTimer Troubles

I am trying to run the code below but it keeps locking up my simulator after the "Tick" is written to the console. It never outputs "Tock" so my guess is that it has to do with the line "NSTimeInterval elapsedTime = [startTime timeIntervalSinceNow];" The IBactions are activated by buttons. timer and startTime are defined in the .h as NST...

Calling a Java Program from a Cocoa Application

Hello, I can't find a decent Cocoa Charting Library so I would like to use JFreechart. Is there any way to call a Java program from a Cocoa Application? I was thinking in writing a java application that returns an image of the chart and I would display it inside my Cocoa app. Thank you, ...

How to resolve an internally-declared XML entity reference using NSXMLParser

I have an XML file that uses internally-declared entities. For example: <?xml version="1.0" encoding="UTF-8"?> ... <!ENTITY my_symbol "my symbol value"> ... <my_element> <my_next_element>foo&my_symbol;bar</my_next_element> </my_element> ... Using the NSXMLParser class, how am I able to resolve the my_symbol entity reference? ...