objective-c

BUG in IPHONE SDK 3.1 secondsFromGMT method of NSTimeZone Returns wrong value

BUG in IPHONE SDK 3.1 secondsFromGMT method of NSTimeZone Returning Wrong value Documentation says: secondsFromGMT Returns the current difference in seconds between the receiver and Greenwich Mean Time. This my Sample code NSTimeZone *tZone =[NSTimeZone timeZoneWithName:@"Asia/Calcutta"]; NSCalendar *calendar = [[NSCalendar alloc] init...

Selecting a subview in a custom UITableViewCell in UITableView

Hi All, I have a UITableView comprised of custom UITableViewCells with some text and a button in them. The cell's allowSelection property is set to NO so that I can tap the button without selecting the cell. I am trying to find a way to know which cell in the table was tapped when the button for that cell is pressed. Is there any way t...

Hide a UIBarButtonItem when in edit mode.

I have a UINavigationController with a UITableViewController which has and two UIBarButtonItems: - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.leftBarButtonItem = self.editButtonItem; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd targ...

@class vs #import

What is the difference when using @class or #import in objective-c? I have seen various tutorials and only a few use @class while most of the others use #import. ...

Working with a file by pathname/URI using Finder + ScriptingBridge

I'm using the generated Finder.h headers from the sdef utility, and it appears that a lot of Finder SB methods require objects of type FinderItem to do anything meaningful with. How would I go about creating one of them objects based on a path to or URI of the file? The farthest I've got is the [SBObject initWithProperties] method bri...

release object added to Core Data?

I am importing a good amount of data into my application using Core Data like so: for (int i = 0; i < [items count]; i++) { Client *entity = (Client*) [NSEntityDescription insertNewObjectForEntityForName:@"Client" inManagedObjectContext:managedObjectContext]; [entity setCompanyName:[[items objectAtIndex:i] objectForKey:@"Compan...

Array and dictionary compatibility

Hi, In version 1.0 i am using NSMutableArray and inside that i am storing NSNumbers like NSMutableArray *myArray; for(int i= 0 ; i < 10 ; i++) [myArray addObject:[NSNumber numberWithInt:i]]; For storing my gameStatus. In Next version(1.1) I want to update myArray like(by storing dictionary inside it)... NSMutableArray *myArray; for...

CMMotionManager and the Gyroscope on iPhone 4

I am trying to simply NSLog the output of the new iPhone 4 Gyroscope. But after reading the documentation and following their sample code I am getting this error. ERROR,Time,300635803.946,Function,"CLLoggingSetFile",could not open locations log /var/mobile/Library/Caches/CoreMotion/CoreMotion.log Even if I just setup my motionManager ...

Accessing unknown class method when trying to use getter

I set a value in one class and then I want to retrieve that value without creating an object for it. When I use classname.variableName from another class(which I declare the variableName as property and synthesize it) I get an unknown class method error. How can I just set an NSString in one class and just reference it from another. I ...

setting limitations (maximum dimensions, rotation) with uiimagepickercontroller

I've come across posts mentioning that you can set the maximum dimensions of a photo returned by the UIImagePickerController camera capture (UIImagePickerControllerSourceTypeCamera), but can't figure out exactly how to do it. Can anyone provide some actual code? I am trying to return an image with maximum width of 768px, and I also want...

UIViewController Auto Rotates on Iphone but not Ipad

Hi all, I have an IPad auto rotation problem. I have a UINavigationController, managing a stack of UIViewControllers. They all implement the method - -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } At the bottom of th...

is [_internal lock] in synthesized accessors the same as @synchronized(self)?

It's fairly well documented that @synthesize atomic settings/getters are implemented with "something" like so: { [_internal lock]; // lock using an object-level lock id result = [[value retain] autorelease]; [_internal unlock]; return result; } The situation I have, I want to access two properties atomically (ie. not u...

How can i use the getter/setter of a Call-Method from Example Code in MailComposer

Hey everyone i have a question regarding the call-methods handling in object-c. I downloaded the apple sample code for the mail composer (http://developer.apple.com/iphone/library/samplecode/MailComposer/Introduction/Intro.html). When the user touches the "Compose Mail"-Button in the sample-code the Methode -(void)displayComposerShee...

How to replace Objective-C 2.0 class method implementation in runtime

I have used class_replaceMethod function and it works good with instance methods, but I it doesn't work with class method replacement. Has anybody idea why and what should I do to replace class method implementation? ...

Block references as instance vars in Objective-C

Hi there, I was wondering if it's possible to store a reference to an anonymous function (block) as an instance variable in Objective-C. I know how to use delegation, target-action, etc. I am not talking about this. Thanks! ...

segmented control to switch images in scrollview iphone

I have a view with a UINavBar in it, and a scrollview beneath that. The nav bar has a segmented button which I want to use to toggle between 2 images to be presented in the scrollview. Both of the images are in the same scrollview but one is hidden to start. I was trying to do this like so: -(IBAction)segmentedControlIndexChanged{ swit...

storing preferences within the app to be used later

How can I store a large float value, like 0.00032012 in the app?? I need to store that number, so when someone click a save preferences button, it stores a variable. Then when I relaunch the app, it will remember that number and post it in a text field. I was thinking of using plist, but how can I store variables in the plist??? Exampl...

NSMutableArray removeObjectAtIndex: throws invalid argument exception.

Hi everybody, I'm writing an application to show some news from a portal. The news are fetched using a JSON file from the Internet and then stored into a NSMutableArray using the CoreData Model. Obviously a user can't delete the news from the JSON file on the Internet, but he can hide them locally. The problems come out here, where I hav...

Shrink UIButton

Hi, I have a application that runs a timer and performs a action 30 times a second. What I want to do is change the size of a UIButton i have so that every time the timer goes around, it changes the UIButton so that it is a little bit smaller. I have played with a bunch of things I have found online and I still cant figure it out. Any ...

Can a UILabel be placed over UIPicker component and the text of the UILabel be updated after user picks a new value in the picker?

How are the user's touches detected if i were to use UILabels that are overlayed on each picker component? I understand how to detect the user's touches on the picker, but I need to update the text of the label after the user make changes a picker component value. My method is not being called after I change the values in the picker comp...