cocoa

handling the logout functionality on the iPhone

This is the first iPhone application i am working on. To use the application, the user has to login to our server. I am done with that part. Now the problem i am facing is how to logout the user from the server, deallocate all the memory and start afresh without quitting the app. After the user logs out, i want the exact same things to...

Sync Services With AddressBook

Hi, I've developed an application to sync the Mac address book with another application. I was using an NSNotification (kABDatabaseChangedExternallyNotification) which are sent every time the address book is edited to do the syncing. However I found that if I 'overloaded' the address book (by adding 20 records really quickly or somethin...

Is there a Cocoa equivalent of Apple Event Manager?

Is there a way to handle Apple Events (namely starting the app from a custom protocol link like myapp://do/something/cool) without using the Carbon APIs? If not, is it safe to assume that these APIs are not going to go away in the next release of OS X? ...

How to observe NSScroller changes?

I have an NSScrollView subclass and I would like to update another NSView based on the current scroll position. I tried KVC-observing the value of [self horizontalScroller] but that never gets called. // In awakeFromNib [[self horizontalScroller] addObserver:self forKeyPath:@"value" ...

Best practices for packaging resources (jpg's, sound, video) in an iPhone app?

I'm a newb iPhone developer writing an app that has several large JPGs and sound files. Everything works ok if I drag these non-code resources into my project. But I am wondering if this is the right way to package my app. In Windows development, I would create a "resource DLL" that keeps the .exe size small. What is the equivalent for...

How can I get the first element in an NSDictionary?

I have an array of NSDictionaries. How can I pull out the first element in the dictionary? NSArray *messages = [[results objectForKey:@"messages"] valueForKey:@"message"]; for (NSDictionary *message in messages) { STObject *mySTObject = [[STObject alloc] init]; mySTObject.stID = [message valueForKey:@...

Release Quickie

How to succinctly handle this situation. I'm not properly releasing contactDictionary in the if statement... NSNumber *pIDAsNumber; ... NSMutableDictionary *contactDictionary = [NSMutableDictionary dictionaryWithDictionary:[defaults dictionaryForKey:kContactDictionary]]; if (!contactDictionary) { con...

NSTableView is not showing my data. Why is that happening?

I'm making a "simple" to-do-list project and running into a few bumps in the road. The problem is that my NSTableView is NOT showing the data from the NSMutableArray "myArray" and I don't know why that is. Can someone point out my mistake? /* IBOutlet NSTextField *textField; IBOutlet NSTabView *tableView; IBOutlet NSButton *button; ...

NSWindowController windowDidLoad not called

I have a simple Cocoa app using a NSWindowController subclass. In the nib I have set: File Owner's class to my NSWindowController subclass The 'Window' outlet of the File's Owner to the main NSWindow in the nib. The init method of my NSWindowController subclass is called (I call super), but not matter what I do windowDidLoad is nev...

netServiceBrowserDidStopSearch not called

I'm now writing a Bonjour service listener class, according to the document here: Currently, it seems working, I can receive "netServiceBrowserWillSearch:" and "didFindService:moreComing:" correctly. However, after a long wait, I cannot receive " netServiceBrowserDidStopSearch:" or "netServiceBrowser:didNotSearch:". Therefore I don't kn...

Adding custom UITableViewCell crashes the simulator.

Im trying to build my application using a custom UITableViewCell. This is the code in my UIViewController that adds the viewCell to the table: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"------- Tableview --------"); static NSString *myIdentifier = @"MyId...

Memory leak in Apples 'Scrolling' sample code

Hi All, I'm using code based on Apple's "Scrolling" sample code - here's where I have a problem: // load all the images from our bundle and add them to the scroll view NSUInteger i; for (i = 1; i <= jNumImages; i++) { NSString *imageName = [NSString stringWithFormat:@"page%d.png", i]; UIImage *image = [UIImage imageNamed:image...

Design views in IB and use them few times with different content?

hi, is it possible to design a view in interfacebuilder and use it dynamically a few times? the view structure is - UIScrollView - UIView - UIImageView - UILabel now i want to dynamically create multiple instances of the UIView in a for loop with different UILabels and UIImageViews. I want to give them side-by-side in the...

how to get NSTextField in custom NSFormatter class

i am new to cocoa and objective-c and creating small application having few NStextFields on the window.I have create custom NSformatter to validate the inputs,at some instance i want to get the NStextField within my custom NSformatter to change its backcolor to red to notify user for wrong input value.I didn't getting how to get the curr...

serializing an NSXMLDocument object

Hi, I have an NSXmlDocument object which is constructed from an XML file. How can i serialize the said document. I have seen NSPropertyListSerialization class, but could not use as it is not plist file. ...

[Cocoa] NSTableView bound to NSArrayController

Within Interface Builder I've got an NSTableView with two columns bound to a vanilla NSArrayController. The NSArrayController has its Content Array bound to an NSMutableArray in my application delegate. I've used further bindings to setup the addition and removal of rows via bindings (magic!). The issue I'm running into now is that I'd ...

Hide a child window from parent window hide all app

Hi guys, new here and new with cocoa. (not so good with english) I have 2 windows one is the header [mainWindow] (setMovableByWindowBackground:YES) and the other is the content [secWindow], child of the header, the header have a button to hide the content. [mainWindow addChildWindow:secWindow ordered:NSWindowBelow]; [mainWindow setMova...

NSOutlineView/NSTreeController - calculate sum of column

I have an NSOutlineView bound to an NSTreeController. My data items are a custom class, let's call them Row, and suppose a Row contains a name and a numeric field called number. All these Rows are found in let's say a RowContainer which has a rows mutable array holding the parent (level 0) rows. Each row also has a children NSMutableAr...

NSString stringWithFormat question

I am trying to build a small table using NSString. I cannot seem to format the strings properly. Here is what I have [NSString stringWithFormat:@"%8@: %.6f",e,v] where e is an NSString from somewhere else, and v is a float. What I want is output something like this: Grapes: 20.3 Pomegranates: 2.5 Oranges: 15.1 What I ...

Get String Instead of Source - Xcode Cocoa

Hello everyone, I have a program that will scan the contents of a website, and display it in a textbox. The problem is that it shows the html source. For example if my html code was: <html> <body> <p>Hello</p> </body> </html> instead of just showing hello, it'll show the code above... How can I get my objective c program to just ...