Problem with Objective C UITabBar at bottom of Screen

When poping up an UIAction Sheet infront of a UITabBar I had some problems getting the buttons to correctly react to presses.
The reason for this turned out to be with the UITabBar having the a listener that was a higher priority than the button on the UIActionSheet.
To solve this you have to add the action [...]

Posted on July 22, 2009 at 2:10 pm by Alastair Munro · Permalink · One Comment
In: Iphone · Tagged with: ,

Confusion with simple NString manipulation in Objective C

Coming from a Java background, I’ve found it extremely difficuilt to do any simple String manipulation.
My first attempt was

NSString *string1  = @"This is a";
NSString *string2 = @" test";
NSString *newString = string1 + string2;

As it turns out this doesn’t work so well. After much frustration I found the following solution

NSString *string1  = @"This is a";
NSString *string2 [...]

Posted on July 22, 2009 at 2:02 pm by Alastair Munro · Permalink · Leave a comment
In: Iphone · Tagged with: ,

iPhone Objective C UIView from Nib (xib) in UIScrollView in UITabBarController

So, thats a huge assed title.  Hopefully it got you here from Google tho, as intended.
If you are here, you have probably scoured the internet for an answer to the above title.
I have a UIView that I want in a UIScrollView, that is in a UITabbedView Controller AND I want to load the UIView from [...]

Posted on February 23, 2009 at 5:06 pm by Jordan Carter · Permalink · 2 Comments
In: Iphone · Tagged with: , , , ,

Iphone UIWebView HTTP Basic Authentication

So I need to send a user to a page that requires a login. I want to save those details in the app and send them with the initial request. But HOW?

#import "NSData+Additions.h"
@implementation Utility
+ (void) addAuthToWebRequest:(NSMutableURLRequest*)requestObj email:(NSString*)email password:(NSString*)password{
NSString *authString = [[[NSString stringWithFormat:@"%@:%@", email, password] dataUsingEncoding:NSUTF8StringEncoding] base64Encoding];
authString = [NSString stringWithFormat: @"Basic %@", authString];
[requestObj setValue:authString forHTTPHeaderField:@"Authorization"];
}

Which [...]

Posted on February 20, 2009 at 11:14 am by Jordan Carter · Permalink · 8 Comments
In: Iphone · Tagged with: , ,

Objective C (java)Static

So I have wanted some static variables (along the lines that Java implements it).  After a while I found my answer.

DatabaseConfig.h
@interface DatabaseConfig : NSObject {
// Database variables
}
+ (NSString*) databaseName;
+ (void) setDatabaseName:(NSString*)dbName;
+ (NSString*) databasePath;
+ (void) setDatabasePath:(NSString*)dbPath;
DatabaseConfig.m
static NSString *databaseName;
static NSString *databasePath;
@implementation DatabaseConfig
+ (NSString*)databaseName{
return databaseName;
}
+ (void)setDatabaseName:(NSString*)dbName{
databaseName = dbName;
}
+ (NSString*)databasePath{
return databasePath;
}
+ (void)setDatabasePath:(NSString*)dbPath{
databasePath = dbPath;
}
@end
Access them like
#import "DatabaseConfig.h"
NSString *name = [...]

Posted on February 18, 2009 at 10:47 am by Jordan Carter · Permalink · Leave a comment
In: Iphone · Tagged with: