objective-c

iPhone internationalization: falling back to a default language

Consider the following situation: We have two Localizable.string files, one in en.lproj and one in it.lproj When the user switches to English or Italian, the proper localized string is loaded using NSLocalizedString(@"keyword", nil) If one of the files is missing the keyword, the string is not retrieved Is there any way to make this ...

Does Apple's Reachability work with 3G connectivity?

I am developing an iPad application, and I am trying to figure out the best way to decide if a user can connect to the Internet. If the user has no connectivity, I will load cached data, otherwise I will load new data. I am trying to use Apple's reachability class for this, and I wanted to see if I am doing this correctly. In applicat...

I can not addObject to NSMutableArray initializedWith 5 string objects

NSMutableArray *array = [[NSArray alloc] initWithObjects:@"Apranax Forte", @"Actified", @"Zostex 125 MG", @"Zoprotec 30 MG", ...

Add a multiple buttons to a view programatically, call the same method, determine which button it was

I want to programatically add multiple UIButtons to a view - the number of buttons is unknown at compile time. I can make one or more UIButton's like so (in a loop, but shorted for simplicity): UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(buttonClicked:) forContro...

Default window shadow dimensions for Snow Leopard?

I would like to emulate the default shadow applied to NSWindows with a CALayer shadow. I can't quite figure out the exact values for the the following properties though: theLayer.shadowOffset = ?; theLayer.shadowRadius = ?; theLayer.shadowOpacity = ?; I assume that the shadowColor is black (the default). Does anyone have an idea wha...

while(1) block my recv thread

Hello. I have a problem with this code. As you can see a launch with an internal thread recv so that the program is blocked pending a given but will continue its execution, leaving the task to lock the thread. My program would continue to receive the recv data socket new_sd and so I entered an infinite loop (the commented code). The prob...

CLang error (objective C): value stored during initialization is never read

Foo *oFoo = [[[Foo alloc] init] autorelease]; This is how I was taught to program in Objective C, yet the CLang error checker complains that the initial value was never read. But oFoo is an object with properties. oFoo itself has no single value. The property values are what matter. oFoo.PropertyA = 1; oFoo.PropertyB = @"Hello, World....

NSOutlineview - strange behavior after reloading data

I have a NSOutlineView which loads data from a data source. The table is displayed in a panel. The items shown in the table are items which belong to an object (the relation is one-to many between the object and the items). I have a list of objects in a combo box (in fact a NSPopupButton), and when I select another object in the combo ...

Unit Testing and Code Coverage Frameworks for Objective-C?

I'm planning to write couple applications for iPhone and wonder if there are any Unit Testing and Code Coverage Frameworks for Objective-C? ...

Add BarButtonItem to Navigation Controller in Popover

Hi everyone, I'm trying to add UIBarButtonItems to a Navigation Controller that is displayed as a popup. I can't seem to add the buttons, and I'm wondering if someone can help me out. Here is the code I have so far: UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:aStudentsViewC...

How can I pass information between 2 different View Controllers?

Hi, This is a simple question: I have 2 different view controllers, and each one has its own data stored in its .m file. I want to take a value, for instance, an integer value (int i=3;) that is declared in ViewController1 and pass it to ViewController2, so I will be able to use that value in the second view controller. Can anyone plea...

Writing to a new line of a file in Objective-C

For some strange reason, the \n and \r escape sequences do not seem to be working in my code. I want to write each NSString on a new line of the file, but it just appends it the last string on one line. Here's the code: for (Entry *entry in self.entries) { NSString *path = @"/Users/me/File.txt"; NSString *string = (@"%@\r\n", ...

Objective-C classes, pointers to primitive types, etc.

I'll cut a really long story short and give an example of my problem. Given a class that has a pointer to a primitive type as a property: @interface ClassOne : NSObject { int* aNumber } @property int* aNumber; The class is instantiated, and aNumber is allocated and assigned a value, accordingly: ClassOne* bob = [[ClassOne alloc] in...

How to auto-scroll UITableView?

I am trying to do something interesting. I am pulling some JSON data and populating cells in a UITableView. How can I make the UITableView scroll ever second or so? I want to give the effect that as new data is coming in, the table is scrolling, so it is streaming. Any ideas? ...

Core Data fetch request with array

I am trying to set a fetch request with a predicate to obtain records in the store whose identifiers attribute match an array of identifiers specified in the predicate e.g. NSString *predicateString = [NSString stringWithFormat:@"identifier IN %@", employeeIDsArray]; The employeeIDsArray contains a number of NSNumber objects that matc...

I want to support UIInterfaceOrientationLandscapeRight and UIInterfaceOrientationLandscapeLeft only

how do I make sure that UIInterfaceOrientationPortraitRight and UIInterfaceOrientationPortraitLeft are not supported. Basically I want my application to be used ONLY in UIInterfaceOrientationLandscapeRight and UIInterfaceOrientationLandscapeLeft I edited the Info.plist file <string>MainWindow</string> <key>UISupportedInterfaceOrient...

Landscape Mode ONLY for iPhone or iPad

I want to create an application that doesn't use Portrait mode. I am not sure if I need to edit the plist or have code in addition to the plist ...

How to convert long timestamp to UTC timestamp on Objective C

Hey I had a iphone app, the code has a method to retrieve current time stamp from iphone and upload to server. Here is my code: long long timestampMillis = (long long)([[NSDate date] timeIntervalSince1970] * 1000); However, one of customer use the app in Japan sent data shown on server is tomorrow time. How can I retrieve UTC timestamp...

How do I change the UIView programmatically?

I have created View A and View B. My window has View A displayed on the screen. I also have a UIButton on View A. I want to switch from View A to View B when I click on the Button. I am not using any UIViewController. Is it possible to switch the views without using controller? I am calling buttonAction method on TOUCHUPINSIDE The prob...

Landscape Mode: Flip image when you flip your iPad

Apple demonstrated Photo's for the iPad. In their demo, they said you can Flip the iPad and it flips the image. How is this result achieved? I've been reading about UIInterfaceOrientation all day and I'm lost Any help would be appreciated. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { U...