This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)sendMailByTitle:(BOOL)title andText:(NSString*)text byViewController:(UIViewController*)vCtr{ | |
self.strText=text; | |
self.strTitle=title; | |
vRef=vCtr; | |
[self emailThisNote]; | |
} | |
-(void)emailThisNote{ | |
Class mailClass = (NSClassFromString(@"MFMailComposeViewController")); | |
if (mailClass != nil) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(int)getRandomNumber:(int)from to:(int)to { | |
return (int)from + arc4random() % (to-from+1); | |
} | |
int randomNumber = [self getRandomNumber:9 to:99]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <netinet/in.h> | |
#import <SystemConfiguration/SCNetworkReachability.h> | |
- (BOOL)connectedToNetwork { | |
// Create zero addy | |
struct sockaddr_in zeroAddress; | |
bzero(&zeroAddress, sizeof(zeroAddress)); | |
zeroAddress.sin_len = sizeof(zeroAddress); | |
zeroAddress.sin_family = AF_INET; | |
// Recover reachability flags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// view GPSViewController.h file | |
// Step 1: add CoreLocation framework in Project | |
// Step 2: include the CoreLocation.h file | |
// implement the following codes | |
#import <CoreLocation/CoreLocation.h> | |
@interface GPSViewController : UIViewController <CLLocationManagerDelegate> { | |
CLLocationManager *locationManager; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWidth, float ovalHeight); | |
{ | |
float fw, fh; | |
if (ovalWidth == 0 || ovalHeight == 0) { | |
CGContextAddRect(context, rect); | |
return; | |
} | |
CGContextSaveGState(context); | |
CGContextTranslateCTM (context, CGRectGetMinX(rect), CGRectGetMinY(rect)); | |
CGContextScaleCTM (context, ovalWidth, ovalHeight); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef __OBJC__ | |
#import <Foundation/Foundation.h> | |
#import <UIKit/UIKit.h> | |
#define HEXCOLOR(c) [UIColor colorWithRed:((c>>24)&0xFF)/255.0 \ | |
green:((c>>16)&0xFF)/255.0 \ | |
blue:((c>>8)&0xFF)/255.0 \ | |
alpha:((c)&0xFF)/255.0]; | |
#endif | |
static inline BOOL isEmpty(id thing) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (BOOL)validateEmail:(NSString *)email { | |
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}"; | |
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; | |
return [emailTest evaluateWithObject:email]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSString-truncateToSize | |
// Fast Fonts | |
// | |
// Created by Stuart Shelton on 28/03/2010. | |
// Copyright 2010 Stuart Shelton. | |
// | |
// NSString truncate function for Objective C / iPhone SDK by | |
// Stuart Shelton is licensed under a Creative Commons Attribution 3.0 | |
// Unported License (CC BY 3.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load html from local file | |
NSString *imagePath = [[NSBundle mainBundle] resourcePath]; | |
imagePath = [imagePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"]; | |
imagePath = [imagePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; | |
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"localpage" ofType:@"html"]; | |
NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile]; | |
[webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString: [NSString stringWithFormat:@"file:/%@//",imagePath]]]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSArray+BinarySearch.h | |
// BinarySearch | |
// | |
// Created by Ole Begemann on 19.04.10. | |
// Copyright 2010 Ole Begemann. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |