Skip to content

Instantly share code, notes, and snippets.

View ChrisRisner's full-sized avatar

Chris Risner ChrisRisner

View GitHub Profile
@ChrisRisner
ChrisRisner / facebook.m
Created November 13, 2012 07:59
ios day 15-2
- (IBAction)tappedSendFacebook:(id)sender {
SLComposeViewController *socialComposerSheet;
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
socialComposerSheet = [[SLComposeViewController alloc] init];
socialComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[socialComposerSheet setInitialText:[NSString stringWithFormat:@"My Tweet!",socialComposerSheet.serviceType]];
[self presentViewController:socialComposerSheet animated:YES completion:nil];
}
[socialComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
NSString *output;
#import <MessageUI/MessageUI.h>
@interface ViewController : UIViewController <MFMailComposeViewControllerDelegate>
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"LocalPage" ofType:@"html" inDirectory:nil];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
//Append javascript
NSString *script = @"<script>alert(\"This is an alert!!\");</script>";
htmlString = [htmlString stringByAppendingString:script];
[self.webView loadHTMLString:htmlString baseURL:nil];
- (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;
}
-(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"]];
}
@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;
@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 / 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
@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 / 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) {