Common method in Swift

1. Check for any field empty in NSDictionary class func checkforEmptyValueinDictioanty(dic:NSDictionary)-> Bool{ for (keyVal, dataVal) in dic {   if (dataVal.length()==0){                 println("\(keyVal): \(dataVal.length())")                 return false             }                 ... Continue Reading →


Use different font text in a Label in swift

let secondLabel=UILabel(frame: CGRectMake(0, 16, _screenWidth-2, 20))         secondLabel.textColor=UIColor.whiteColor()         secondLabel.textAlignment=NSTextAlignment.Center         secondLabel.font=UIFont(name: "Arial", size: 12)         bottomView.addSubview(secondLabel)                  let attrSting=NSMutableAttributedString(string: "I agree to the Terms of Service and Privacy Policy.")             ... Continue Reading →

SavE and Retrieve data using NSUserDefaults in iOS

SavingNSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];// saving an NSString[prefs setObject:@"TextToSave" forKey:@"keyToLookupString"];// saving an NSInteger[prefs setInteger:42 forKey:@"integerKey"];// saving a Double[prefs setDouble:3.1415 forKey:@"doubleKey"];// saving a Float[prefs setFloat:1.2345678 forKey:@"floatKey"];// This is suggested to synch prefs, but is not needed (I didn't put it in my tut)[prefs synchronize];RetrievingNSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];// getting an NSStringNSString *myString = [prefs stringForKey:@"keyToLookupString"];// getting... Continue Reading →

MultiThreading in iOS

@implementation RootViewController @synthesize array;   - (void)viewDidLoad { [super viewDidLoad];   self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Load" style:UIBarButtonItemStyleDone target:self action:@selector(loadData)];   NSMutableArray *_array = [[NSMutableArray alloc] initWithCapacity:10000]; self.array = _array; [_array release]; }   - (void) loadData {   /* Operation Queue init (autorelease) */ NSOperationQueue *queue = [NSOperationQueue new];   /* Create our NSInvocationOperation to... Continue Reading →

Blog at

Up ↑

%d bloggers like this: