cocoa

iPhone SDK: After invalidating a Timer, how can I use it again?

I have set up an animation in Xcode using an NSTimer, and It kept repeating over and over, so i used this command: else if(gordon.image == pigImage11) [animationTimer invalidate]; So, when gordon (a UIImageView) image is set to pigImage11, The timer invalidates, this gave the desired effect of stopping the animation constantly rep...

Whats the best place to set a View Controller ivar?

I have an XML reader class which I initialize with a URL - (id)initWithURL:(NSURL *)url This class adds objects to an array in the calling class using an instance variable // in the interface ViewController *viewController; // in the implementation [viewController addObject:theObject]; Now, I initialize my XML reader class, then s...

NSNotificationCenter: Do objects receive notifications on the same thread they are posted?

I am interested in knowing whether I can expect the observing object's method to be pushed onto the stack before the posting object's method has been completed and removed. ...

Where can I find a good tutorial on iPhone/Objective c multithreading?

I'm just starting to use multithreading and was looking for a good explanation. I'm not sure if there are differences in how multithreading works on Macs and iPhones. Does anyone have a good link to tutorials with example code? Thanks. ...

Remove newline character from first line of NSString

How can I remove the first \n character from an NSString? Edit: Just to clarify, what I would like to do is: If the first line of the string contains a \n character, delete it else do nothing. ie: If the string is like this: @"\nhello, this is the first line\nthis is the second line" and opposed to a string that does not contain a ...

sending attachment using applescript in cocoa

I have made a short applescript that sends an email with an attached vcs-file. Now I want to integrate this script in my cocoa application. I have tried the following code that i found on the internet: NSAppleScript *mailScript; NSString *scriptString= [NSString stringWithFormat:@"the applescript"]; mailScript = [[NSAppleScript alloc] i...

how to show strings randomly in uitableViewCell?

i want to show 4 options(strings) randomly on uitableviewcell how do i achieve this??? ...

AnalysisTool / Clang results: ivar naming convention violation

AnalysisTool (a Clang GUI front end) states some fo my ivars are improperly named: Specifically: the name of instance variable 'groupName' doesn't start with the 'm' prefix What does the 'm' prefix stand for in Cocoa? Should I be using it? Or is this a false positive. ...

Cocoa WebKit - detecting CSS rollover/hover

I have a WebView displaying a HTML page, linking to a CSS file. The CSS file makes use of the pseudoclasses :active and :hover for rollover effects. Q. How can I tell, in my WebView, when :active and :hover have been called? I would like to intercept these calls and act on them programmatically within Cocoa. Thanks. ...

NSAutoreleasePool carrying across methods?

I'm building an iPhone application where I detach some threads to do long-running work in the background so as not to hang the UI. I understand that threads need NSAutoreleasePool instances for memory management. What I'm not sure about is if the threaded method calls another method - does that method also need an NSAutoreleasePool? Exa...

Cocoa - Localized string from NSDate, NSCalendarDate...

I'm using NSDate to get a string such as "18 Jun 09", with code: NSDate *theDate = [NSDate date]; NSString *dateString = [theDate descriptionWithCalendarFormat:@"%d %b %y" timeZone:nil locale: nil]; This works, but only results in an English output. I need the output to be localized in the user's default language. Doe...

Change NSNumberFormatter's negative format from (xxx.xx) to -xxx.xx

I want to change my NSNumberformatter from displaying negative numbers with parenthesis around them to putting the minus sign in front (or whatever the localized standard is). I would assume I could do this with setNegativeFormat: but reading Apple's oh so thorough docs I am left scratching my head: setNegativeFormat: Sets the fo...

NSUnknownKeyException, KVC compliance code not working

the following piece of code which gets successfully built and also seems alright to me but doesn't work... mind that i am new to key value coding and your help will be greatly appreciated... in table view delegate didSelectRowAtIndexPath: method here the categoriesList is a simple table with 5 entries NSUInteger row = [indexPath row]; ...

NSArray to C array

can we convert NSArray to c array. if not what alternatives are there.[suppose i need to feed the c array in opengl functions where the c array contains vertex pointer read from plist files] ...

AquaticPrime "Regular" License?

Hi Everyone: I am looking at using AquaticPrime for my key generator for a Cocoa shareware app. For those of you who don't know about it, you can check it out here: http://aquaticmac.com/. However, I am running into a problem when I attempt to implement it. I don't want my users to have to copy and paste a whole dictionary into my ap...

Why don't I declare NSInteger with a *

I'm trying my hand at the iPhone course from Stanford on iTunes U and I'm a bit confused about pointers. In the first assignment, I tried doing something like this NSString *processName = [[NSProcessInfo processInfo] processName]; NSInteger *processID = [[NSProcessInfo processInfo] processIdentifier]; Which generated an error, after t...

How do I include calls to methods only present in one operating system version when compiling for multiple versions?

I have an app that is being compiled with a minimum system requirement of Tiger (OS X 10.4), but I need to include some code to deal with Spaces if the app is executing on Leopard (OS X 10.5). How do I do this? (The call I need to make is to -[NSWindow setCollectionBehavior:]). ...

How to monitor file locking to track down a deadlock?

Our application is occasionally hanging while it saves, where the core data raw file is being left locked (perhaps by our spotlight importer). We've verified that it's at a low-level file level, not at the core data level. What I'm trying to do is figure out how to monitor the application while it's running so if I get this hang, I can...

How to perform Callbacks in Objective-C

I am a beginner programmer in Objective-C. Can anyone please tell me how to perform call back functions in Objective-C. I would just like to see some completed examples and I should understand it. Thanks a lot ...

Is this a job for NSTimer? Looping interface changes

A button on my inferface, when held down, will perform a series of changes on other parts of my interface. For instance, for one second some text will turn blue, then a UImageView will change its image for two secs ...etc etc... This series of changes will keep looping thru the same steps as long as the button is held down. I've neve...