- (void)toMeAgain {
UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"myIdentifier"];
[self.navigationController pushViewController:vc animated:YES];
}
/// Represents an instance of a class.
struct objc_object {
Class isa OBJC_ISA_AVAILABILITY;
};
/// A pointer to an instance of a class.
typedef struct objc_object *id;
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
[button addTarget:self action:@selector(myLovelyFunction:) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Touch me, baby!" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[view addSubview:button];
- (void)myLovelyFunction:(id)sender {
// do something
}
[button setTag:91];
- (void)myLovelyFunction:(id)sender {
UIButton *button = (UIButton*)sender;
if (button.tag == 91) {
// super
} else {
// good too
}
}
...у нас есть аватарка пользователя, по нажатию на которую открывается экран с дополнительной инфой о пользователе...
...кнопка должна быть кнопкой, ссылка - текстом, а картинка - картинкой...
- (void)loadZip {
NSString *mainUrl = [self.server stringByAppendingString:@"/files/YOURZIP.zip"];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:mainUrl]];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *respons,
NSData *dat,
NSError *connectionError) {
if (!connectionError) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:@"YOURZIP.zip"];
NSError *error;
BOOL flag = [dat writeToFile:appFile options:NSDataWritingAtomic error:&error];
if (flag) {
NSLog(@"You cool");
} else {
NSLog(@"%@", error.localizedDescription);
[self loadZip];
}
} else {
NSLog(@"%@",[connectionError localizedDescription]);
}
}];
}