#define degreesToRadians(x) (M_PI * x / 180.0)

[UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationCurveEaseOut
animations:^{
object.transform = CGAffineTransformRotate(object.transform, degreesToRadians(90));
} completion:nil
];

See https://github.com/jimsblogfiles/RotateSomething for project & files

NSString *dirtyString = @”I just want text @#$!”;
NSCharacterSet *nonAlphaNumericSet = [[ NSCharacterSet alphanumericCharacterSet ] invertedSet ];

NSString *cleanString = [[ dirtyString componentsSeparatedByCharactersInSet:nonAlphaNumericSet ] componentsJoinedByString:@”" ];

NSLog(@”>%@”, cleanString);

2012-02-12 22:29:24.645 Untitled 2[9145:707] >Ijustwanttext

//viewdidload or similar
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleUpdateRequest:) name:@”myObject” object:nil];

////////////////////////////////////////////////////
////////// FROM A BUTTON

//button action or similar
-(IBAction)doSomething:(id)sender {

[[NSNotificationCenter defaultCenter] postNotificationName:@”myObject” object:sender];

}

//handler
-(void)handleUpdateRequest:(NSNotification *)notif {

NSLog(@”>>>%i”,[notif.object tag]);

}

OR

////////////////////////////////////////////////////
////////// TABLE CELL

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSNumber *indexPath_row = [[NSNumber alloc] initWithInt:indexPath.row];
[[NSNotificationCenter defaultCenter] postNotificationName:@”myObject” object:indexPath_row];

}

//handler
-(void)handleUpdateRequest:(NSNotification *)notif {

NSLog(@”>>>%i”,[notif.object intValue]);

}

NSMutableArray *imageArray = [[NSMutableArray alloc]init];

for (int i = 1; iy <= 40; i++) {
[imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"s%02i.png", i]]];
}

UIImageView * ryuJump = [[[UIImageView alloc] initWithFrame:
CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]autorelease];
ryuJump.animationImages = imageArray;
ryuJump.animationDuration = 2.1;
ryuJump.contentMode = UIViewContentModeCenter;

[someview addSubview:ryuJump];

[ryuJump startAnimating];
[imageArray release];

-(NSString*)urlEncoded:(NSString*)str {

NSString *escapedUrlString = [str stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
return escapedUrlString;

}

-(NSString*)urlDecoded:(NSString*)str {

NSString *cleanUrlString = [str stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
return cleanUrlString;

}

NSString *devStr = @”http://localhost/dri/json?foo=#bar&something=true&miscc=Foo bar!”;

NSLog(@”devStr: %@”,devStr);

NSString *encString = [self urlEncoded:devStr];
NSLog(@”encString: %@”,encString);

NSString *decString = [self urlDecoded:encString];
NSLog(@”decString: %@”,decString);

UIImage *image = [UIImage imageNamed:@"greatimage.png"];
UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
imgView.frame = CGRectMake(0, 0, 320, 90);
[self.view addSubview:imgView];
[imgView release];

// a button
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(targetMethod:) forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(0.0, 0.0, 160.0, 40.0);
[self.view addSubview:button];

////////////////////////////////////////
// Button with background images
////////////////////////////////////////

UIButton *bttn = [UIButton buttonWithType:UIButtonTypeCustom];
bttn.frame = CGRectMake(0, 200, 97, 38);
[bttn setTitle:@"Dev One" forState:UIControlStateNormal];
[bttn addTarget:self action:@selector(targetMethod:) forControlEvents:UIControlEventTouchUpInside];

UIImage *bttnImageNormal = [UIImage imageNamed:@"button.png"];
[bttn setImage:bttnImageNormal forState:UIControlStateNormal];

UIImage *bttnImageSelected = [UIImage imageNamed:@"button-selected.png"];
[bttn setImage:bttnImageSelected forState:UIControlStateHighlighted];

[self.view addSubview:bttn];

-(IBAction)targetMethod:(id)sender {

NSLog(@”targetMethod”);

}

#define DEBUGGING

#ifdef DEBUGGING
# define LogBasic(fmt,…) fprintf(stderr,” :: %s\n”, [[NSString stringWithFormat:fmt, ##__VA_ARGS__] UTF8String]);
#else
# define LogBasic(…)
#endif

#ifdef DEBUGGING
# define LogFunc(fmt,…) fprintf(stderr,”%s :: Line %d >> %s\n”, __PRETTY_FUNCTION__, __LINE__, [[NSString stringWithFormat:fmt, ##__VA_ARGS__] UTF8String]);
#else
# define LogFunc(…)
#endif

#ifdef DEBUGGING
# define LogAlert(fmt, …) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] “, __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__] delegate:nil cancelButtonTitle:@”Ok” otherButtonTitles:nil]; [alert show]; }
#else
# define LogAlert(…)
#endif

See https://github.com/jimsblogfiles/PrefixDefaultStuff for project & files.

#import <Foundation/Foundation.h>

@interface RemotePreferences : NSObject {
NSMutableData *incomingData;
}

@end

@implementation RemotePreferences

-(id)init {

self = [super init];

if (self) {

NSURL *url = [NSURL URLWithString: @"http://example.com/configs.plist"];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0];
__unused NSURLConnection *fetchConn = [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];

}

return self;

}

- (void)connection:(NSURLConnection *)sender didReceiveData:(NSData *)data {

if (!incomingData) {
incomingData = [[NSMutableData alloc] init];
}

[incomingData appendData:data];

}

- (void)connectionDidFinishLoading:(NSURLConnection *)sender {

NSDictionary *prefsDict = [[[NSDictionary alloc] init] autorelease];
prefsDict = [NSPropertyListSerialization propertyListFromData:incomingData mutabilityOption:NSPropertyListImmutable format:nil errorDescription:nil];

[[NSUserDefaults standardUserDefaults] registerDefaults:prefsDict];

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

}

- (void)connection:(NSURLConnection *)sender didFailWithError:(NSError *)error {
NSLog(@"connection failed: %@", [error localizedDescription]);
}

-(void)dealloc {
FuncLog();

[super dealloc];

[incomingData release];
incomingData = nil;

}

//- (NSURLRequest *)connection:(NSURLConnection *)c willSendRequest:(NSURLRequest *)req redirectResponse:(NSURLResponse *)res {}
//- (void)connection:(NSURLConnection *)sender didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)ch {}
//- (NSCachedURLResponse *)connection:(NSURLConnection *)sender willCacheResponse:(NSCachedURLResponse *)cachedResponse{}

@end

self.tabBarController.selectedIndex = 3;
[self.tabBarController.selectedViewController viewDidAppear:YES];

if inside a custom tabbarcontroller doing this

//call viewWillDisappear in the current view
[self.selectedViewController viewWillDisappear:YES];

//change view
self.selectedIndex = tabID;

//call viewDidAppear in the current view
[self.selectedViewController viewDidAppear:YES];

© 2012 James Border Suffusion theme by Sayontan Sinha