cocoa

How do I get the current hour using Cocoa?

How do I get the current hour in Cocoa using Objective-C? ...

UITableViewCell not getting updated.

For every entry in the table view cell, I need a button at right then some text and again a button at the left. At the button click event I need to change the text (left/right button clicked.) and remove either of the buttons depending on the text conditions. I am not able to remove the buttons using cellForRowAtIndexPath method. I tried...

The mac os tiger and About panel of Germany Version

I have a app , now I want to edit it with the Germany Version , but I found a funny thing: Under the Tiger I found that when the About panel show the info with Germanic character, if a line cound not fill the characters it will show remains to the next line, as example: Copyright © 2001-2009 AAA Co., LTD , if one can show the Copyrigh...

How to disable the Quit func under the mutilDocument environment ?

I haove a mutilDocument App , I found that when I open a window with the method : [NSApp beginSheet: [MultiWin window] modalForWindow: mainWindows modalDelegate: nil didEndSelector: nil contextInfo: nil]; The Quit func in mainmeny already highlight , this can confuse the user that the Quit app func can work under this vironment.I want t...

How to add these object with name to the array by this order?

I have some object with name , just like button 1 , button 2 , button 11 ,button 111 , I want to add this object to a array by this order: button 1 ,button 2 , button 11 , button 111, but I found that these object can add the array by thhis order: button 1 , button 11,button 111 , button 2.why ? Thank you for your answer! ...

iPhone Persistent Storage

I need to store certain information while my application is executing and again fetch it at the time the application starts. I tried storing it in XML using GData but didn't succeed. I used the NSFileHandle it doesn't give me an error but it fails to create a .txt file for read / write purpose. Is there any other way of storing and retri...

Using Cocoa to detect when a running application plays audio

I'm looking into writing an app that runs as a background process and detects when an app (say, Safari) is playing audio. I can use NSWorkspace to get the process ID's of the currently running applications but I'm at a loss when it comes to detecting what those processes are doing. I assume that there is a way to listen in on a process a...

Is the NSDocumentDirectory unique for a given application?

I would like to save some user-specific data in my iPhone app. I was looking at the SQLite sample, and it is using something similar to this: NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask ,YES ); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *writableDBPath = [documentsDi...

Animated cell reordering in an NSTableView

Is there a good technique or example code demonstrating how to implement animated cell reordering? I have a custom cell class and regular reordering works fine, but I'd like to animate as much of it as possible (preferable something like the tab reordering in safari except in a tableview). Any ideas? Thanks. ...

Storing a passwords in NSString without being readable in memory

I need to store passwords in NSString objects; however, I would like some way to obfuscate them, so they cannot be read directly from memory. This is a Mac OS X (10.5) application, but a solution that also works on iPhone would be much appreciated. ...

How do you check for sanity in objective-c and cocoa?

What is the preferred method of checking for sanity in objective-c and cocoa? ...

problem writing a NSMutableArray to file in cocoa

A real beginners question. I have a NSView subclass in which I create a NSMutableArray containing NSValues. When I want to write the array to a file using writetofile:atomatically: the file is created but it contains none of the NSValues that the mutable array does contain. Does anyone know how I successfully can write this mutable array...

Rounding numbers in Objective-C

Hi, I'm trying to do some number rounding and conversion to a string to enhance the output in an Objective-C program. I have a float value that I'd like to round to the nearest .5 and then use it to set the text on a label. For example: 1.4 would be a string of: 1.5 1.2 would be a string of: 1 0.2 would be a string of: 0 I've spe...

Xcode debugging: View value of NSNumber ??

Is it possible to see the numeric value of an NSNumber in the debugger datatip on in the variable watch window? I store an Integer value in NSNumber and want to see this value during debugging. I tried some of the data formatters in the debugger already, but it wasn't much help. ...

Using a constant NSString as the key for NSUserDefaults

I'm using NSUSerDefaults to store user preferences. I remember reading somewhere that setting the keys as constants is a good idea - and I agree. The following code is what I currently have: [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:polygon.numberOfSides] forKey:@"polygonNumberOfSides"]...

What is the best way to implement syntax highlighting of source code in Cocoa?

I'm working on Cocoa Application that should be able to analyze and highlight a source code written in such languages as Objective-C, SQL, JavaScript, Python etc. The text should be editable too (by using NSTextView, for example). Please advise what is the best way to implement such feature in Mac OS X 10.5. There is no need to support...

Releasing NSData causes exception...

Hi, Can someone please explain why the following code causes my app to bomb? NSData *myImage = UIImagePNGRepresentation(imageView.image); : [myImage release]; If I comment out the 'release' line, the app runs... but a few times calling the function containing this code and I get a crash - I guess caused by a memory leak. Even if I...

Is this an objective-c memory leak?

I know that if you do the following you most certainly have a memory leak: id foo = [[NSObject alloc] init]; foo = nil; But, what if you're using self.foo, a property with retain? And your code instead looks like the following: foo = [[NSObject alloc] init]; self.foo = nil; Is that still a memory leak since the accessor releases th...

NSNotification between sibling views

Using a UITabBar, I have 4 sibling views (one per tab item). When the app loads, the first tab item and view are visible. That first view has an IBAction that posts an NSNotification. Each of the other three views have observers for the notification but they cannot "hear" the notification until they are first made visible by touching ...

how to remove files and directory in a appointed path?

Now I want to remove some files and directory in a appointed path. such as file extension is .png and directries are named as abc , In the appointed directory maybe have some subdirectory , how to get the array of the files and directories at the appointed? and then how to remove them? I found a method: NSArray *paths = NSSearchPathForDi...