objective-c

iPad orientation on launch problem in portrait (bottom home button)

Hi.... I've an iPad app that supports all orientation... my problem was on the start up of the application. In case of landScapeRight and landScapeLeft and portrait(top home button) the views shows correctly but when the app start in portrait (bottom home button) the views show in landscape mode... I've implemented the - (void) willRo...

Difference between an variable set to nil and 0

if (myFloat == nil){ \\Do Method } In the above situation, the method will run only if myFloat is nil. Will it also run if myFloat was set to 0? ...

Objective-C ref count and autorelease

Hey guys, suppose the following code: int main (int argc, const char * argv[]) { //[...] Rectangle* myRect = [[Rectangle alloc] init]; Vector2* newOrigin = [[[Vector2 alloc] init] autorelease]; // ref count 1 [newOrigin setX: 50.0f]; [myRect setOrigin: newOrigin]; // ref count 2 [myRect.origin setXY: 25.0f :1...

how can you find out if an NSObject has a certain property?

Let's say in Apple API version 1.0, there is a class NSFoo with a property 'color'. API 1.1 adds property 'size'. I want to know whether I can use the getter: myFoo.size [myFoo respondsToSelector:@selector(getSize)] doesn't work as expected. What's the correct way to find out if an object has a property? Thanks! ...

How will I have to update how I program for iPhones now with iOS4?

For example, preparing a launch screen of 320 x 480 would have to be changed.... How is that going to work for us? Are programmers always going to have to be submitting a high-res that will be scaled down for old devices such as the iphone 3g? ...

Designing DAOs around a JSON API for iPhone Development

So I've been trying to design a clean way of grabbing data for my models in iPhone land. All the data for my application is coming from JSON API's. So right now when a VC needs some models, it does the JSON call itself (asynch) and when it receives the data, it builds the models. It works, but I'm trying to think of a cleaner method whe...

if (self = [super init]) vs. if ((self = [super init]))

Was just doing a code review and started to wonder: I thought if (self = [super init]) checks whether assigning return value of [super init] to variable self was successful or not (value of operation). Thus (self = nil) would actually be TRUE. I thought if ((self = [super init])) checks what is the value of self after assignment (value...

About get satisfactory api

I am develping an application in objective c for iphone, I added Getsatisfactoy thing in my code, there if i want to add reply to my application , in their example [[[NSUserDefaults standardUserDefaults] objectForKey:@"SRC_ME_ACCOUNT"] objectForKey:@"id"] ,in this id always nil , anything i have to set for this , what will be id will tak...

drawRect is not refreshing the screen

I have this code in my drawRect method float aValue = .0167f; float fValue = 20; for(int i=1; i<=6; i++) { CGContextSelectFont(context, "Arial", fValue, kCGEncodingMacRoman); CGContextSetCharacterSpacing(context, 0); CGContextSetTextDrawingMode(context, kCGTextFill); NSString *...

Release variable and assigning it again

What is the preferred and/or correct way to release an NSMutableString (or any other class for that matter) instance and assign a new instance to the same variable in Objective-C on the iPhone? Currently I'm using [current release]; current = [NSMutableString new]; but I understand that the following works, too. NSMutableString *new...

IPhone memory problems...

Hi, I am working on an App that is already been made but Memory Management was not considered in the development stages. So what can I do to keep the App memory usage low as soon as I get a memory warning? Is there any general tool or some piece of code that I can use to release any unused memory? ...

All colors work except whiteColor

const CGFloat *color = CGColorGetComponents([[UIColor whiteColor] CGColor]); CGContextSetFillColor(context, color); I have black background. While working this above code not sure whats wrong most of the colors work like redColor, purpleColor, greenColor, yellowColor but whiteColor, grayColor does not work. when i use whiteColor screen...

How to create constant NSString by concatenating strings in Obj-C ?

Hi guys, I'm trying to instanciate a constant NSString by concatanating other NSString instances. Here is what I'm doing in my implementation file : static NSString *const MY_CONST = @"TEST"; static NSString *const MY_CONCATENATE_CONST = [NSString stringWithFormat:@"STRING %@", MY_CONST]; It leads to the following compilation error ...

Are these really the steps I need to take to finally program for iPhone?

First I went and purchased: Beginning iPhone Development: Exploring the iPhone SDK And it said I should know Objective-C Then I went and purchased Learn Objective–C on the Mac by Mark Dalrymple, Scott Knaster And it said I should know C then now I'm at the beginning with Learn C on the Mac by Dave Mark So this is the long journey I...

Help! Obj-C/Iphone programming: extracting string from html text and reading off line by line

hihi, I have this html text response from a particular website: <tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="crsdsdfs2221.jpg">crash-2221.jpg</a></td><td align="right">14-Jun-2010 14:29 Notice for every line, there is this href=".__", which is an image file with random name and random format. I wo...

How to check if a NSMutableArray contains a value (null) or not ?

Hi all, I have a NSMuatableArray object which contains "N" number of objects and i want to check wheather mutablearray contains (null) value or any othervalue. In NSString there is an method called isEqualToString: Wheather any simmilar method available for NSMutableArray? How can i do this? ...

Caching results from a PHP webservice for iPhone

I'm building an app that retrieves a JSON dataset from a PHP server. The app has a view that displays a "feed" of several different newly added or updated items from the web server. The app loads 20 of the newest items to start with, and the user can subsequently load 20 more older items, and 20 more, and so on. I want this data to per...

Does this singleton pattern make sense?

@implementation MySingletonClass static MySingletonClass *sharedInstance = nil; + (MySingletonClass*)sharedInstance { @synchronized(self) { if (sharedInstance == nil) { sharedInstance = [[self alloc] init]; } } return sharedInstance; } + (id)alloc { @synchronized(self) { if (sharedIn...

UIGestureRecognizer on MPMoviePlayerViewController

Hi there I'm wondering if any of you have encountered similar problems and of course happened to find a proper or not so proper (but working) solution/workaround. I'm using a MPMoviePlayerViewController and I'm trying to a add Swipe-Gesture Recognizers onto the MPMoviePlayerViewControllers view. moviePlayerViewController = [[MPMovi...

iPad UIWebView Action Toolbar Display

I have a pdf open in a UIWebView and I would like to allow the option to open it in Pages. That is, I would like the action toolbar to become displayed when the user taps on the UIWebView (just like in Safari for iPad). How do you enable this capability in UIWebView, if possible? ...