Skip to content

Instantly share code, notes, and snippets.

View ChrisRisner's full-sized avatar

Chris Risner ChrisRisner

View GitHub Profile
- (IBAction)tappedShowNewView:(id)sender {
SecondViewController *secondViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"secondViewController"];
[self presentModalViewController:secondViewController animated:YES];
}
@class SecondViewController;
@protocol SecondViewControllerDelegate <NSObject>
- (void)doSomethingWithSecondViewController:(SecondViewController *)secondViewController;
@end
@interface SecondViewController : UIViewController
@property (nonatomic, weak) id <SecondViewControllerDelegate> delegate;
- (IBAction)tappedCloseModal:(id)sender;
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <NSURLConnectionDelegate> {
NSMutableData* _receivedData;
}
@property (weak, nonatomic) IBOutlet UITextField *txtName;
@property (weak, nonatomic) IBOutlet UILabel *lblData;
- (IBAction)btnFetchData1:(id)sender;
- (IBAction)txtFetchData2:(id)sender;
@ChrisRisner
ChrisRisner / fetchdata1.m
Created October 20, 2012 01:44
iOS Day 8
- (IBAction)btnFetchData1:(id)sender {
NSString *queryString = [NSString stringWithFormat:@"http://chrisrisner.com/Labs/day7test.php?name=%@", [self.txtName text]];
NSMutableURLRequest *theRequest=[NSMutableURLRequest
requestWithURL:[NSURL URLWithString:
queryString]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[theRequest setHTTPMethod:@"POST"];
NSURLConnection *con = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (con) {
@interface ViewController : UIViewController <UITextViewDelegate, UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *txtFieldOne;
@property (weak, nonatomic) IBOutlet UITextField *txtFieldTwo;
@property (weak, nonatomic) IBOutlet UITextView *txtView;
@property (weak, nonatomic) IBOutlet UIButton *btnButton;
- (IBAction)tappedButton:(id)sender;
@end
@ChrisRisner
ChrisRisner / AppDelegate1.h
Created October 30, 2012 22:05
iOS Day 10
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) NSString *info;
@end
@ChrisRisner
ChrisRisner / LoadingData.m
Created November 5, 2012 04:13
iOS Day 11
- (IBAction)tappedLoadData:(id)sender {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
self.lblInfo.text = [defaults objectForKey:@"infoString"];
}
@ChrisRisner
ChrisRisner / AppDelegate.h
Created November 6, 2012 04:35
iOS Day 12
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
-(void)displayManagedObject:(NSManagedObject *)obj {
self.txtName.text = [obj valueForKey:@"name"];
self.txtInfo.text = [obj valueForKey:@"info"];
self.txtNumber.text = [(NSNumber *)[obj valueForKey:@"number"] stringValue];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
self.lblCreateDate.text = [dateFormatter stringFromDate:[obj valueForKey:@"createDate"]];
self.lblUpdateDate.text = [dateFormatter stringFromDate:[obj valueForKey:@"updateDate"]];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
NSDictionary *item =[itemsArray objectAtIndex:[indexPath row]];
cell.textLabel.text = [item objectForKey:@"name"];
return cell;
}