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
function sendAPNSSandbox($vDeviceToken, $message) { | |
$ctx = stream_context_create(); | |
stream_context_set_option($ctx, 'ssl', 'local_cert', 'apns/ck.pem'); | |
stream_context_set_option($ctx, 'ssl', 'passphrase', 'Createanet'); | |
$fp = stream_socket_client( | |
'ssl://gateway.sandbox.push.apple.com:2195', $err, | |
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); | |
if (!$fp) return false; |
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
import UIKit | |
@IBDesignable class CustomTextField: UITextField { | |
@IBInspectable var placeholderColor: UIColor = UIColor.lightGrayColor() { | |
didSet { | |
let canEditPlaceholderColor = self.respondsToSelector(Selector("setAttributedPlaceholder:")) | |
if (canEditPlaceholderColor) { | |
self.attributedPlaceholder = NSAttributedString(string: placeholder, attributes:[NSForegroundColorAttributeName: placeholderColor]); | |
} |
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 *checkPasswordForWhitespace = [password.text componentsSeparatedByString:@" "]; | |
NSLog(@"%@", checkPasswordForWhitespace); | |
if ([checkPasswordForWhitespace count] > 1) { | |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Whitespace" message:@"Please remove the whitespace from your password." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; | |
[alert show]; | |
return; |
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
//Place outside any other methods | |
- (BOOL)validateEmail:(NSString *)emailStr { | |
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:emailStr]; | |
} | |
//Place where you wish to validate the email | |
if(![self validateEmail:[emailAddress text]]) { | |
//Didn't enter correct email value |
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 *param3 = nil; | |
NSRange start3 = [cell.text rangeOfString:@"thestartcharacterhere"]; | |
if (start3.location != NSNotFound) | |
{ | |
param3 = [cell.text substringFromIndex:start3.location + start3.length]; | |
NSRange end3 = [param3 rangeOfString:@"theendcharacterhere"]; | |
if (end3.location != NSNotFound) | |
{ | |
param3 = [param3 substringToIndex:end3.location]; | |
} |
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
//Place in viewDidLoad | |
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { | |
// iOS 7 | |
[self prefersStatusBarHidden]; | |
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; | |
} else { | |
// iOS 6 | |
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; | |
} | |