diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d0ce7de --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +# OS X +.DS_Store + +# Xcode +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +profile +*.moved-aside +DerivedData +*.hmap +*.ipa + +# CocoaPods +Pods diff --git a/.project b/.project new file mode 100644 index 0000000..e46f05b --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + ToolBox - Objective-C + + + + + + + + diff --git a/Date and Time/currentDataTime b/Date and Time/currentDataTime new file mode 100644 index 0000000..c7d781f --- /dev/null +++ b/Date and Time/currentDataTime @@ -0,0 +1,3 @@ +//Get Current Date and time: +NSCalendar *gregorian = [NSCalendar currentCalendar]; +NSDateComponents *dateComponents = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:[NSDate date]]; \ No newline at end of file diff --git a/Files/copyFile b/Files/copyFile new file mode 100644 index 0000000..ac156d7 --- /dev/null +++ b/Files/copyFile @@ -0,0 +1,2 @@ +//Copy a file from x to y +[[NSFileManager defaultManager] copyItemAtPath:x toPath:y error:nil]; \ No newline at end of file diff --git a/Files/documentsFolderPath b/Files/documentsFolderPath new file mode 100644 index 0000000..4aaa2c5 --- /dev/null +++ b/Files/documentsFolderPath @@ -0,0 +1,3 @@ +//Get the path to the Documents folder: +NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); +NSString* documentsDirectory = [paths objectAtIndex:0]; \ No newline at end of file diff --git a/Launch Applications/dialPhoneNumber b/Launch Applications/dialPhoneNumber new file mode 100644 index 0000000..83354ec --- /dev/null +++ b/Launch Applications/dialPhoneNumber @@ -0,0 +1,2 @@ +//Dial a Phone Number (iPhone Only) +[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://9662256888"]]; \ No newline at end of file diff --git a/Launch Applications/googleMaps b/Launch Applications/googleMaps new file mode 100644 index 0000000..8d15e64 --- /dev/null +++ b/Launch Applications/googleMaps @@ -0,0 +1,3 @@ +//Open Google Maps app with directions between two lat/long points +NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f&dirflg=d", start.latitude, start.longitude, finish.latitude, finish.longitude]; +[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]]; \ No newline at end of file diff --git a/Launch Applications/launchMail b/Launch Applications/launchMail new file mode 100644 index 0000000..ea17fcb --- /dev/null +++ b/Launch Applications/launchMail @@ -0,0 +1,2 @@ +//Launch the Apple Mail +[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://mymail@myserver.com"]]; \ No newline at end of file diff --git a/Launch Applications/launchMessages b/Launch Applications/launchMessages new file mode 100644 index 0000000..86956b0 --- /dev/null +++ b/Launch Applications/launchMessages @@ -0,0 +1,2 @@ +//Open the Messages app with a specific phone number: +[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:123456789"]]; \ No newline at end of file diff --git a/Launch Applications/launchSafari b/Launch Applications/launchSafari new file mode 100644 index 0000000..4060e5f --- /dev/null +++ b/Launch Applications/launchSafari @@ -0,0 +1,2 @@ +//Open an URL in Safari +[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com/"]]; \ No newline at end of file diff --git a/Launch Applications/numberofLaunches b/Launch Applications/numberofLaunches new file mode 100644 index 0000000..ea3bd7e --- /dev/null +++ b/Launch Applications/numberofLaunches @@ -0,0 +1,10 @@ +NSUserDefaults *countDefaults; +int launchCount; + +countDefaults = [NSUserDefaults standardUserDefaults]; +launchCount = [countDefaults integerForKey:@"launchCount" ] + 1; +[countDefaults setInteger:launchCount forKey:@"launchCount"]; +[countDefaults synchronize]; + + +NSLog(@"Launch number: %i", launchCount); \ No newline at end of file diff --git a/Methods/checkObjectSupportsMethod b/Methods/checkObjectSupportsMethod new file mode 100644 index 0000000..2ba179e --- /dev/null +++ b/Methods/checkObjectSupportsMethod @@ -0,0 +1,4 @@ +//Check to make sure an objects support a method before calling it: +if ([item respondsToSelector:@selector(activateBOP:)]) { + [item activateBOP:closeBOP]; +} \ No newline at end of file diff --git a/Methods/logNameOfClassAndFunction b/Methods/logNameOfClassAndFunction new file mode 100644 index 0000000..bfe8836 --- /dev/null +++ b/Methods/logNameOfClassAndFunction @@ -0,0 +1,2 @@ +//Log the name of the class and function: +NSLog(@"%s", __PRETTY_FUNCTION__); \ No newline at end of file diff --git a/Navigation/UITabBarBackground b/Navigation/UITabBarBackground new file mode 100644 index 0000000..5769693 --- /dev/null +++ b/Navigation/UITabBarBackground @@ -0,0 +1,2 @@ +UIImage *tabBarBackground = [UIImage imageNamed:@"TabBarOverlay.png"]; +[rootController.tabBar setBackgroundImage:tabBarBackground]; \ No newline at end of file diff --git a/Navigation/blackStatusBar b/Navigation/blackStatusBar new file mode 100644 index 0000000..a8a0d4f --- /dev/null +++ b/Navigation/blackStatusBar @@ -0,0 +1,2 @@ +//Change the status bar to black +[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque]; \ No newline at end of file diff --git a/Navigation/hideBackButton b/Navigation/hideBackButton new file mode 100644 index 0000000..f734271 --- /dev/null +++ b/Navigation/hideBackButton @@ -0,0 +1 @@ +self.navigationItem.hidesBackButton = YES; \ No newline at end of file diff --git a/Navigation/hideStatusBar.m b/Navigation/hideStatusBar.m new file mode 100644 index 0000000..090220e --- /dev/null +++ b/Navigation/hideStatusBar.m @@ -0,0 +1,2 @@ +//Hide the status bar +[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]; \ No newline at end of file diff --git a/Navigation/navBarStyle b/Navigation/navBarStyle new file mode 100644 index 0000000..08e132f --- /dev/null +++ b/Navigation/navBarStyle @@ -0,0 +1,2 @@ +//Change the style of the navigation bar (from in a view controller): +self.navigationController.navigationBar.barStyle = UIBarStyleBlack; \ No newline at end of file diff --git a/Network/network b/Network/network new file mode 100644 index 0000000..e2d83ae --- /dev/null +++ b/Network/network @@ -0,0 +1,5 @@ +//Show the network Activity Indicator +[UIApplication sharedApplication].networkActivityIndicatorVisible = YES; + +//Hide the network Activity Indicator +[UIApplication sharedApplication].networkActivityIndicatorVisible = NO; \ No newline at end of file diff --git a/Power/power b/Power/power new file mode 100644 index 0000000..0f73d2a --- /dev/null +++ b/Power/power @@ -0,0 +1,2 @@ +//Prevents iPhone goes into sleep mode +[UIApplication sharedApplication].idleTimerDisabled = YES; \ No newline at end of file diff --git a/Touch Events/screenTouches b/Touch Events/screenTouches new file mode 100644 index 0000000..8d94639 --- /dev/null +++ b/Touch Events/screenTouches @@ -0,0 +1,3 @@ +//Screen touches method + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {} \ No newline at end of file diff --git a/Touch Events/startStopResponding b/Touch Events/startStopResponding new file mode 100644 index 0000000..d58e0c6 --- /dev/null +++ b/Touch Events/startStopResponding @@ -0,0 +1,5 @@ +//stop responding to touch events +[[UIApplication sharedApplication] beginIgnoringInteractionEvents]; + +//activate the touch events +[[UIApplication sharedApplication] endIgnoringInteractionEvents]; \ No newline at end of file diff --git a/Types/customEnumType b/Types/customEnumType new file mode 100644 index 0000000..86e73bb --- /dev/null +++ b/Types/customEnumType @@ -0,0 +1,4 @@ +//Own enum type: +typedef enum { + a = 0, b = 1, c = 2 +} enumName; \ No newline at end of file diff --git a/UILabel/alignText b/UILabel/alignText new file mode 100644 index 0000000..1783805 --- /dev/null +++ b/UILabel/alignText @@ -0,0 +1 @@ +titleLabel.textAlignment = UITextAlignmentCenter; \ No newline at end of file diff --git a/UILabel/fontSize b/UILabel/fontSize new file mode 100644 index 0000000..9646b3e --- /dev/null +++ b/UILabel/fontSize @@ -0,0 +1 @@ +[textView setFont:[UIFont fontWithName:@"Helvetica" size:16]]; \ No newline at end of file diff --git a/UIScrollView/configuration b/UIScrollView/configuration new file mode 100644 index 0000000..aa82f6b --- /dev/null +++ b/UIScrollView/configuration @@ -0,0 +1,2 @@ +[scrollView setScrollEnabled:YES]; +[scrollView setContentSize:CGSizeMake(320, 1400)]; \ No newline at end of file diff --git a/UITableView/tableViewTemplate b/UITableView/tableViewTemplate new file mode 100644 index 0000000..50f0e44 --- /dev/null +++ b/UITableView/tableViewTemplate @@ -0,0 +1,23 @@ +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *cellIdentifier = @"Cell"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; + if(cell == nil) + { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle + reuseIdentifier:cellIdentifier]; + // Do something here...................... + } + // Do something here too ......................... + return cell; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return ; +} + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return ; +} \ No newline at end of file diff --git a/UITextView/fontAndSize b/UITextView/fontAndSize new file mode 100644 index 0000000..b266ed9 --- /dev/null +++ b/UITextView/fontAndSize @@ -0,0 +1 @@ +[thankYouTextView setFont:[UIFont fontWithName:@"Helvetica" size:16]]; \ No newline at end of file diff --git a/UIView/alertWindow b/UIView/alertWindow new file mode 100644 index 0000000..8810174 --- /dev/null +++ b/UIView/alertWindow @@ -0,0 +1,3 @@ +//Display an alert window: +UIAlertView* alert = [[[UIAlertView alloc] initWithTitle:@"Warning" message:@"too many alerts" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease]; +[alert show] \ No newline at end of file diff --git a/UIView/backgroundColor b/UIView/backgroundColor new file mode 100644 index 0000000..442f685 --- /dev/null +++ b/UIView/backgroundColor @@ -0,0 +1 @@ +self.view.backgroundColor = [UIColor colorWithHue:1.0 saturation:0.0 brightness:0.6 alpha:1.0]; \ No newline at end of file diff --git a/UIView/changeBackButtonTitle b/UIView/changeBackButtonTitle new file mode 100644 index 0000000..10d3c3d --- /dev/null +++ b/UIView/changeBackButtonTitle @@ -0,0 +1,8 @@ +//Change the title on the back button on a UINavigationView. +//Use this code on the UINavigationController before pushing the view + +UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style: UIBarButtonItemStyleBordered target:nil action:nil]; + + +self.navigationItem.backBarButtonItem = backBarButtonItem; +[backBarButtonItem release]; \ No newline at end of file diff --git a/UIView/displayNewView b/UIView/displayNewView new file mode 100644 index 0000000..adcbc8f --- /dev/null +++ b/UIView/displayNewView @@ -0,0 +1,2 @@ +//Display a new view +[self presentModalViewController:(UIViewController *) animated:YES]; \ No newline at end of file diff --git a/UIView/fadeAwayUIView b/UIView/fadeAwayUIView new file mode 100644 index 0000000..8df520f --- /dev/null +++ b/UIView/fadeAwayUIView @@ -0,0 +1,5 @@ +//Fade away a UIView by animating the alpha down to 0: +[UIView beginAnimations:nil context:NULL]; +[UIView setAnimationDuration:1]; // fade away over 1 seconds +[aView setAlpha:0]; +[UIView commitAnimations]; \ No newline at end of file diff --git a/UIView/getAppName b/UIView/getAppName new file mode 100644 index 0000000..a4b593d --- /dev/null +++ b/UIView/getAppName @@ -0,0 +1,2 @@ +//Get the name of the app +self.title = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; \ No newline at end of file diff --git a/UIView/notificationBadge b/UIView/notificationBadge new file mode 100644 index 0000000..7aec8f4 --- /dev/null +++ b/UIView/notificationBadge @@ -0,0 +1,2 @@ +//red notification badge on app +[UIApplication sharedApplication].applicationIconBadgeNumber = 10; diff --git a/UIView/pushViewToNavBar b/UIView/pushViewToNavBar new file mode 100644 index 0000000..7d9e42f --- /dev/null +++ b/UIView/pushViewToNavBar @@ -0,0 +1,2 @@ +//Push another view controller onto the Navigation Bar: +[self.navigationController pushViewController:anotherVC animated:YES]; \ No newline at end of file diff --git a/UIView/quartzDrawArc b/UIView/quartzDrawArc new file mode 100644 index 0000000..82473b0 --- /dev/null +++ b/UIView/quartzDrawArc @@ -0,0 +1,3 @@ +//Quartz draw arc +CGContextRef ctxt = UIGraphicsGetCurrentContext(); +CGContextAddArc(ctxt, x, y, radius, startDeg, endDeg); \ No newline at end of file diff --git a/UIView/roundedCornerOrBorder b/UIView/roundedCornerOrBorder new file mode 100644 index 0000000..cd18d85 --- /dev/null +++ b/UIView/roundedCornerOrBorder @@ -0,0 +1,4 @@ +//Add rounded corners and/or a border around any UIView item (self) +self.layer.borderColor = [UIColor whiteColor]. +self.layer.cornerRadius = 8; // rounded corners +self.layer.masksToBounds = YES; // prevent drawing outside border \ No newline at end of file diff --git a/UIView/setTitle b/UIView/setTitle new file mode 100644 index 0000000..81f7edf --- /dev/null +++ b/UIView/setTitle @@ -0,0 +1 @@ +viewController.title = @"Title Here..."; \ No newline at end of file diff --git a/UIViewController/presentViewController b/UIViewController/presentViewController new file mode 100644 index 0000000..6bd3ec7 --- /dev/null +++ b/UIViewController/presentViewController @@ -0,0 +1,3 @@ +ViewController *viewController = [[ViewController alloc] init]; +viewController = @"Title Here..."; +[self.navigationController viewController animated:YES]; \ No newline at end of file diff --git a/User Defaults/saveBoolToUserDefaults b/User Defaults/saveBoolToUserDefaults new file mode 100644 index 0000000..566a922 --- /dev/null +++ b/User Defaults/saveBoolToUserDefaults @@ -0,0 +1,2 @@ +//Save bool to User Defaults +[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"Yes Bool"]; \ No newline at end of file diff --git a/User Defaults/saveOrGetStringToUserDefaults b/User Defaults/saveOrGetStringToUserDefaults new file mode 100644 index 0000000..7b96e19 --- /dev/null +++ b/User Defaults/saveOrGetStringToUserDefaults @@ -0,0 +1,7 @@ +//Save a NSString into NSUserDefaults: +NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; +[defaults setObject:loginName forKey:kUserLoginName]; + +//Get an NSString from NSUserDefaults: +NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; +NSString* loginName = [defaults stringForKey:kUserLoginName]; \ No newline at end of file diff --git a/Vibrate/vibrate b/Vibrate/vibrate new file mode 100644 index 0000000..5e9f207 --- /dev/null +++ b/Vibrate/vibrate @@ -0,0 +1,2 @@ +//Make the device vibrate: +AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); \ No newline at end of file