If you get the error “warning:comparison between pointer and integer”, odds are you are thinking right, but implementing your comparison wrong.
ur doin it wrong
if(count == 2) {
the right way
if([count intValue] == 2) {
If you get the error “warning:comparison between pointer and integer”, odds are you are thinking right, but implementing your comparison wrong.
ur doin it wrong
if(count == 2) {
the right way
if([count intValue] == 2) {
Recently while developing an app, I ran into an issues where the iPhone keyboard was sliding up and covering the text field. I did some quick searching on the on the internet an came across some sample code on StackOverflow (http://stackoverflow.com/questions/1247113/iphone-keyboard-covers-text-field)
I took the code that was given and spun it for my own uses. After placing the code in the project, I linked the hidden textFields ‘Editing Did Begin” and “Editing Did End” events to the “slideFrameUp” and “slideFrameDown” methods.
The end result works great!
-(IBAction) slideFrameUp;
{
[self slideFrame:YES];
}
-(IBAction) slideFrameDown;
{
[self slideFrame:NO];
}
-(void) slideFrame:(BOOL) up
{
const int movementDistance = 50; // tweak as needed
const float movementDuration = 0.3f; // tweak as needed
int movement = (up ? -movementDistance : movementDistance);
[UIView beginAnimations: @"anim" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.view.frame = CGRectOffset(self.view.frame, 0, movement);
[UIView commitAnimations];
}
This is how to get the version number of your app at run time. I find this helpful in to use in the “about” section of my apps. The version number is read from your apps info.plist file.
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
There are several ways to problematically detect if an iPhone has an internet connection, but most of them cant tell you how the iPhone is connected to the internet.
Apple has sample code to accomplish just this task. The Reachability class is not shipped with the SDK, but is part of a sample project of the same name. http://developer.apple.com/iphone/library/samplecode/Reachability/index.html
Set up:
Sample Usage:
Reachability *reachability = [Reachability sharedReachability];
[reachability setHostName:@"www.JoshHighland.com"];
NetworkStatus remoteHostStatus = [reachability remoteHostStatus];
if(remoteHostStatus == NotReachable) {
//no internet connection
}
else if (remoteHostStatus == ReachableViaWiFiNetwork) {
//wifi connection found
}
else if (remoteHostStatus == ReachableViaCarrierDataNetwork) {
//EDGE or 3G connection found
}
The wrong way to do string comparisons in the iPhone SDK
if(myTitle == @"HELLO")
The right way
if([myTilte isEqualToString:@"HELLO"])