-(BOOL)imageExists:(NSString*)imageName inThisDirectory:(NSString*)dirName {

NSFileManager *filemgr = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

// the documents directory plus whatever is in dirName then imageName
NSString *documentsDirectory = [NSString stringWithFormat:@"%@/%@",[paths objectAtIndex:0], dirName];

if ([filemgr fileExistsAtPath: [documentsDirectory stringByAppendingPathComponent:imageName] ] == YES) {

return YES;

} else {

return NO;

}

}

Jul 122011

$protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https'?'https':'http';
print "The protocol is $protocol";
?>

taken directly from:

http://readytousesolutions.com/phpblog/php-tutorial-get-protocol/

Split a string into an array of strings by using NSString's componentsSeparatedByString:

NSString *myString = @"This is a test";
NSArray *myWords = [myString componentsSeparatedByString:@" "];

// myWords is now: [@"This", @"is", @"a", @"test"]
If you need to split on a set of several different characters, use NSString's componentsSeparatedByCharactersInSet:

NSString *myString = @"Foo-bar/blee";
NSArray *myWords = [myString componentsSeparatedByCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString:@"-/"]
];

// myWords is now: [@"Foo", @"bar", @"blee"]

http://www.idev101.com/code/Objective-C/Strings/split.html


// toggle the I have accepted all your terms and conditions button
-(IBAction)actHasAccepted:(id)sender {
buttonHasAccepted.selected = !buttonHasAccepted.selected;
}

// the button that should trigger whatever
-(IBAction) doSomethingIfUserAgrees:(id) sender {

//
if (!buttonHasAccepted.selected) {

UIAlertView *alert =
[[UIAlertView alloc] initWithTitle: @"Error"
message: @"You must agree copy"
delegate: self
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
[alert show];
[alert release];

} else {

// Carry on

}

}

[datePicker setDate:[NSDate date] animated:YES];

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data {
NSLog(@"EWYFPicOneViewController - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data {");
NSString *string = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@" data == %@",string);

}

[_tabBarController.moreNavigationController.navigationBar setHidden:YES];

or

[tabBarController.moreNavigationController.navigationBar setHidden:YES];


var flashvars = {};
flashvars.clickTag = "http://www.some.com";
var params = {};
var attributes = {};
swfobject.embedSWF("some.swf","myAlternativeContent", "300", "250", "8.0.0", false, flashvars, params,attributes);

NSNumberFormatter* nf = [[[NSNumberFormatter alloc] init] autorelease];
nf.positiveFormat = @”0.##”;
NSString* s = [nf stringFromNumber: [NSNumber numberWithFloat: val]];
return s;

NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"MMM dd, yyyy"];
NSString *strDate = [dateFormatter stringFromDate:[NSDate date]];

NSLog(@”NSUserDefaults dump: %@”, [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);

© 2012 James Border Suffusion theme by Sayontan Sinha