Archive by Author

How to define private methods … sort of

There is no private or protected methods concept in Objective-C. I think it is related to the architecture of invoking method in Objective-C. Each method is invoked like [self method] style or [self performSelector:@selector(method)]. Internally, Objective-C runtime resolves method implementation by searching method name. This architecture gives flexibility to call method and also allows to have “category” but it is hard to support private method.

Leave a comment Continue Reading →

How to remember the setting (user defaults) easily

NSUserDefautls object automatically loads and saves small information. Along with primitive value like BOOL, integer or float, NSUserDefaults can handle objects like NSArray, NSData, NSDictionary, NSString.

// Save a default
[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"ShowWarning"];

// Read  BOOL warning value from NSUserDefaults
BOOL showWarning = [[NSUserDefaults standardUserDefaults] boolForKey:@"ShowWarning"];
Leave a comment Continue Reading →

Capture view contents into an UIImage object

By combining UIGraphicsBeginImageContext() and -renderInContext in CALayer, you can draw contents into a image (UIImage) object. It is like screen capture.

UIGraphicsBeginImageContext(view.frame.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Leave a comment Continue Reading →

Set border around the view

There is no border property in UIView…. classes but we can access CALayer class to set border. Since layer property is defined in the UIView class, all of UIView inherited class can use this property to set border. It needs to have #import <QuartzCore/QuartzCore.h> to access CALayer.

view.layer.borderWidth = 1;
view.layer.borderColor = [[UIColor grayColor] CGColor];
Leave a comment Continue Reading →

Calling selectors with multiple arguments – Stack Overflow

In Objective-C, a selector’s signature consists of:

  1. The name of the method (in this case it would be ‘myTest’) (required)
  2. A ‘;’ (colon) following the method name if the method has an input.
  3. A name and ‘:’ for every additional input.
Leave a comment Continue Reading →

Accessing AppDelegate instance

AppDelegate object can access from any class in the same application like below. Methods or properties shared between controllers can be defined under application delegates.

SomeAppDelegate *appDelegate
  = (SomeAppDelegate *)[[UIApplication sharedApplication] delegate];
Leave a comment Continue Reading →

How to access special directory on the iphone device

Use NSSearchPathForDirectoriesInDomains(). First argument “NSDocumentDirecotry” is the key to specify special directory, in this case Document directory under the application. The method returns absolute path expression.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                               NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSLog(@"NSDocumentDirectory is %@", documentsDirectory);
Leave a comment Continue Reading →

Repeating background image in native iPhone app – Stack Overflow

Apparently a UIColor is not necessarily a single color, but can be a pattern as well. Confusingly, this is not supported in Interface Builder.

Instead you set the backgroundColor of the view (say, in -viewDidLoad) with the convenience method +colorWithPatternImage: and pass it a UI Image. For Instance:

Leave a comment Continue Reading →

Applying animation while resizing or moving the view

Animation can be applied while its frame, bounds, center, transform, alpha… is being changed. ┬áThe key is set start and end values between beginAnimations and commitAnimations, so called animation block.

Leave a comment Continue Reading →

Create alert dialog

UIAlertView takes care of this

UIAlertView *alert = [[UIAlertView alloc]
                       initWithTitle:@"Alert View"
                       message:@"Here is an alert message"
                       delegate:nil
                       cancelButtonTitle:@"Cancel"
                       otherButtonTitles:@"OK", nil];
[alert show];

// Since alert object is allocated above, it must  be released here
[alert release];
Leave a comment Continue Reading →
Situs Togel 4D Bo Togel Bandar Togel Deposit Pulsa Agen Togel Deposit Ovo Togel Bet 100 Perak Bandar Togel Terbesar Toto Togel Bandar Togel 10 Situs Togel Terpercaya Daftar Akun Togel Resmi Daftar Bandar Togel Terbesar Slot Bet 250 Perak Bandar togel terpercaya Agen Slot dan Togel agen togel deposit ovo situs togel 4d Nama Situs Togel Terpercaya slot pragmatic Kpktoto Slot Bonus 100 Situs Judi Slot Terbaik Slot Gacor Slot Online Slot Pragmatic Bandar Togel Terpercaya Link Slot Gacor Dingdong Togel Slot Deposit Pulsa Situs Slot Terpercaya Situs Slot Judi Online Agen Slot Online BO Togel Bandar Togel Terpercaya 5 Bandar Togel Terpercaya Agen Togel Bet 100 Perak Situs Judi Slot Online Toto Togel Agen Togel Resmi Bandar Togel Deposit Pulsa Dingdong Togel Situs Togel Terbesar Bandar Darat Togel Togel Toto Online Togel Singapore BO Togel Bet 100 Perak Agen Togel Deposit Pulsa Situs Bandar Togel Hadiah 4D 10 Juta 10 Situs Togel Terpercaya 5 Bandar Togel Terpercaya Situs Slot Deposit Pulsa Agen Slot Online Togel Hari Bandar Togel Terbesar Akun Slot Bet Agen Togel Online Game Situs Judi Slot Situs Judi Slot Resmi Game Slot Game Judi Slot Online Slot Game Bonus New Member 100 Agen Togel terpercaya 10 Situs Togel Terpercaya Agen Togel Online Agen Togel Terpercaya Agen Togel Singapore Togel Toto Macau Situs Togel Resmi Situs Togel Terpercaya 10 Situs Togel Terpercaya Situs Togel Terpercaya Nama Situs Togel Terpercaya Situs Bandar Judi Togel Situs Togel BRI Online 24 Jam situs togel dan slot situs togel deposit pulsa SITUS TOGEL DEPOSIT VIA DANA situs togel online Situs Togel Resmi situs togel terbaik 5 bandar togel terpercaya BANDAR DARAT TOGEL Bandar Lotre Togel Bandar Togel Bet 100 Rupiah Bandar Togel Hadiah 2D 100rb bandar togel hadiah 4d 10 juta terpercaya BANDAR TOGEL HADIAH 4D 10 JUTA Situs Slot Bet 100 Perak situs bandar togel terpercaya Bandar Togel Deposit Pulsa Situs Slot Situs Slot deposit Pulsa Situs Judi Slot Bonus 100 Agen Slot Dan Togel Toto Slot Bandar Togel Hadiah 4D 10 Juta Situs Togel Online Situs Slot Togel Terlengkap Agen Slot BO Togel Agen Togel Online Situs Bandar Togel Dan Slot Bandar Togel Lengkap Situs Togel Togel Deposit Pulsa Slot Gacor Bandar Togel Lengkap Situs Slot Agen Slot dan Togel 5 Bandar Togel Terpercaya Bo Togel dan Slot Situs Togel Toto Togel Bandar Darat BANDAR TOGEL HADIAH 4D 10 JUTA Judi togel Togel Hadiah 2D 100rb Bandar Togel Dan Slot Togel Bet 100 Lotre Togel bandar darat togel 5 bandar togel terpercaya Situs Togel Terpercaya bandar judi terpercaya Bandar Togel Terbesar Bandar Togel Online bandar togel bandar togel terpercaya hadiah terbesar judi togel bandar togel terbesar situs judi online bandar togel terbesar Togel Online Bandar Togel Bolak Balik Dibayar Bandar Togel Lengkap situs togel Bandar Togel Togel Hadiah 4d Terbesar bandar togel hadiah terbesar Bandar Togel Hadiah 4d Terbesar judi togel Togel Online Terbaik Situs Togel Resmi Situs Togel Terbesar Bandar Lotre Togel Togel Kamboja Dingdong Togel Bandar Togel Terbesar dan Terpercaya Bandar Togel Terpercaya Bandar Togel Online Daftar Bandar Togel Agen Togel Online Agen Togel Togel Deposit Via Dana 5 Bandar togel terpercaya bandar togel terpercaya agen togel terpercaya slot online situs judi slot Situs Bonus New Member Slot Gacor 10 Situs Bandar Togel Slot Online Agen Slot Online Slot Pragmatic Slot Pragmatic Agen Togel Lengkap Bandar Togel Hadiah 4d 10 Juta Slot Resmi Bo Togel Situs Togel Terpercaya 5 Bandar Togel Terpercaya Agen Bo Togel Bandar Togel Slot Pragmatic Judi Slot Pragmatic Situs Slot Bonus New Member 100 Ribu agen togel online Agen Togel Terpercaya toto togel 5 Bandar Togel Terpercaya Bandar Togel Terpercaya Bandar Togel Online Situs Togel Resmi Agen Slot Judi Slot Online Toto Macau 10 Situs Togel Terpercaya Togel Seratus Slot Pulsa Tanpa Potongan Situs Slot Gacor pasaran togel lengkap Bo Togel Togel deposit pulsa Agen Judi Slot Online Terpercaya Situs Slot Gacor Mesin Slot Situs Judi Slot Online Bandar Togel dan Slot Agen Judi Slot Pragmatic Slot Online Via Dana Link Slot Gacor Agen Slot Terpercaya Bo Togel Online 10 Situs Togel Terpercaya dan Terbesar Game Slot Situs Game Slot Online Agen Judi Togel Bandar Togel Daftar Akun Togel Online Bandar Togel Terpercaya Hadiah Terbesar