NSString* string= @"Some String";
NSData* data=[string dataUsingEncoding:NSUTF8StringEncoding];
read moreNSString* string= @"Some String";
NSData* data=[string dataUsingEncoding:NSUTF8StringEncoding];
read more#include <CommonCrypto/CommonDigest.h>
@implementation YourClass
-(NSString*)getExecutableFileMD5Signature{
NSBundle *bundle = [NSBundle mainBundle];
NSDictionary *info = [bundle infoDictionary];
NSString *execName = [info objectForKey:@"CFBundleExecutable"];
NSData *data = [NSData dataWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.app/%@", NSHomeDirectory(), execName, execName]];
return [self cHash:@"md5" data:data];
}
-(NSString*)cHash:(NSString*)algo data:(NSData*)data{
NSData *rdata;
if ([algo isEqualToString:@"sha1 ...
read moreNSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
NSLog(@"Current Locale: %@", [[NSLocale currentLocale] localeIdentifier]);
NSLog(@"Current language: %@", currentLanguage);
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *) space {
if([[space authenticationMethod] isEqualToString:NSURLAuthenticationMethodServerTrust]) {
// Note: this is presently only called once per server (or URL?) until
// you restart the app
if(shouldAllowSelfSignedCert) {
return YES; // Self-signed cert will be accepted
} else {
return NO; // Self-signed cert will be rejected
}
}
return NO;
}
- (BOOL)connection:(NSURLConnection ...
read more//Start 180 degrees rotation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
refreshArrow.transform = CGAffineTransformMakeRotation(M_PI);
[UIView commitAnimations];
- (BOOL)textField:(UITextField )textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString )strin{ //Check that response is should be maximum 5 characters if ([strin length] > 0) { return [textField.text length] < 5; } return YES; }
read more
//We need have this to clear background for UITableView on iPad
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
[itemTable setBackgroundView:nil];
[itemTable setBackgroundView:[[[UIView alloc] init] autorelease]];
}
read more//We need to make this in master page to change title in back button on details page
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Master" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
read more- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"BigListCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
CGRect labelFrame =
CGRectMake(CGRectGetMinX(cell.frame)+50,
CGRectGetMinY(cell.frame), CGRectGetWidth(cell.frame)-150,
CGRectGetHeight(cell.frame));
UILabel *label = [[UILabel alloc]
initWithFrame:labelFrame ...
read more-(NSString *)getStringfromDate:(NSDate *)date{
if (!dateFormatter) {
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd-MMM-yyyy"];
}
return [[dateFormatter stringFromDate:date] uppercaseString];
}