objective-c

What is wrong with this syntax?

I have #imported the FirstViewController.h and i get the error "expected ':' before '.' token" NSString *myString = RoutineTitle.text; [FirstViewController.routines addObject:myString]; What am i doing wrong? Someone please enlighten me! Thanks, Sam ...

objective-c code formating

what would be a good way to format this piece of code? UIBarButtonItem *prev = [[UIBarButtonItem alloc] initWithTitle:@"Prev" style:UIBarButtonItemStyleBordered target:self action:@selector(setDateRangeClicked:)]; ...

Objective C - Animation Blocks, multiparameters

Hello, I have a question... how is programmatically reached the Animation blocks? [UIView beginAnimations:@"repositionAnimation" context:nil]; // ----------------------------------------------------------------------------- [view setFrame:viewRect]; [view setAlpha:0]; ... ... // ----------------------------------------------------...

How to programmatically determine a Cocoa plugin bundle's garbage collection settings?

On Mac OS X using Objective-C 2, plugin bundles can be compiled with one of three garbage collection settings: Not Supported Supported (-fobjc-gc) Required (-fobjc-gc-only) How can one programmatically query a compiled plugin bundle to determine which of these three settings was used? ...

Match first word of a phrase in a String.

I am using the GTMRegex class from the Google toolbox for mac (in a Cocoa / Objective-C) app: http://code.google.com/p/google-toolbox-for-mac/ I need to do a match and replace of a 3 word phrase in a string. I know the 2nd and 3rd words of the phrase, but the first word is unknown. So, if I had: lorem BIFF BAM BOO ipsem and lorem B...

When to use static string vs. #define

Hi all. I am a little confused as to when it's best to use: static NSString *AppQuitGracefullyKey = @"AppQuitGracefully"; instead of #define AppQuitGracefullyKey @"AppQuitGracefully" I've seen questions like this for C or C++, and I think what's different here is that this is specifically for Objective C, utilizing an object, a...

Cocoa: NSMutableString gives warning with stringValue

This works: NSString *myVar = @"whatever"; NSDecimalNumber *myNum = [NSDecimalNumber decimalNumberWithString:@"10"]; myVar = [myNum stringValue]; This version with mutable string produces warning "assignment from distinct Objective-C type": NSMutableString *myVar = [NSMutableString stringWithString:@"whatever"]; //UPDATE: CORRECT...

How to display a loading gif image in iphone application while uiwebview content loads

I have a uiwebview in my iphone application. I want to show a loading gif image which is located in my application , until complete contents of my uiwebview loads . Can anybody suggest a method ? ...

Cocoa: Testing to find if an NSString is immutable or mutable?

This produces an immutable string object: NSString* myStringA = @"A"; //CORRECTED FROM: NSMutableString* myStringA = @"A"; This produces a mutable string object: NSMutableString* myStringB = [NSMutableString stringWithString:@"B"]; But both objects are reported as the same kind of object, "NSCFString": NSLog(@"myStringA is type: ...

Objective-C Cocoa-Iphone Bind label to variable

Hi all, I am a complete newbie to mac/objective-c. My question is: I wonder if it's possible to bind a UILabel text to a variable, for not having to manually set the text when value change. I explain it better, on mac os, when I open a new finder window and delete a file, then the global free space in the taskbar is changing. And that ...

Xcode - how to include c library and header file to cocoa project?

How do I add c library to Xcode Cocoa project? Or what is the best option, I don't want to copy them into Cocoa project directory. I have a C project called a which compiles into library a.dylib and header file a.h, the project is located in it's own directory. I want to use this library from my objective-c application in Xcode. How ...

How to implement Magnifier

how to implement magnifier tool in cocoa using obj c ...

Showing File Copy Status on a Progress Bar

Hello, I am trying to perform a low-level file copy but also display my progress using a determinate progress bar. Is there any way I can do this? I have looked on many mail archives, and one blog post explaining on how to do it in carbon which didn't work for me. ...

Dot notation - Does it take parameters?

Hello there, Is it correct if I say that [anIstance aMethod]; is equivalent to anIstance.aMethod; --? If it is the case, what about methods which take one ore more parameters? Does the following statement [anIstance aMethod : aParameter]; have an equivalent dot notation? I have tried with anIstance.aMethod : aParameter; ...

problem related to NSString

I have 1 NSString *abc = @"Hardik"; i have NSMutableArray *array; now i had written [array addobject:abc]; then i'm printing,NSLog(@"array = %@", array); but i'm getting NULL why? I have declared NSMutableArray *array; in a.h file i had set @property(nonatomic,retain)NSMutableArray *array; @synthesize array; and i have synthesize it ...

NSNumberFormatter subclass working in 10.6 but failing in 10.5 with generic error

Hi everyone. I'm subclassing NSNumberFormatter to allow the currency symbol to be optional. Here's my code: - (BOOL)getObjectValue:(out id *)anObject forString:(NSString *)aString range:(inout NSRange *)rangep error:(out NSError **)error { if (rangep == NULL){ NSRange newRange = NSMakeRange(0, [aString length]); ran...

Create subfolder in NSDocumentDirectory

hello, I just wanted to know is it's possible to create a subfolder in the NSDocumentDirectory and write data into that created folder, like: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *dirPath =[[paths objectAtIndex:0] stringAppendingPathComponent:@"TestFolder"]; NSS...

Getting position of the annotation relative to screen

I'd like to acquire the position (not map coordinates) of the annotation relative to the screen. For example, for an annotation on the map, I'd like to know how far that particular pin is from the top left corner (0,0). I've looked at the documentations, and it does not provide information on its absolute or relative location. I'll lo...

How to disable keyboard tap sound on iphone?

How do we disable the keyboard tap sound programatically? I am sure it's a setting in UItextfield. ...

How to vibrate an iPhone ad infinitum

Wondering what code in objective-c should I use to shake the iPhone continuously... ...