[read article]




- (IBAction)styleAction:(id)sender


UIActionSheet *styleAlert = [[UIActionSheet alloc] initWithTitle:@"Choose a UIBarStyle:"










// use the same style as the nav bar

styleAlert.actionSheetStyle = (UIActionSheetStyle)self.navigationController.navigationBar.barStyle;


[styleAlert showInView:self.view];

[styleAlert release];


[read article]



    NSString* newStr = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];

[read article]



#pragma mark - UITableViewDataSource


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return [_posts count];



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";


    PostTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (!cell) {

        cell = [[PostTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];



    cell.post = [_posts objectAtIndex:indexPath.row];


    return cell;



#pragma mark - UITableViewDelegate


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    return [PostTableViewCell heightForCellWithPost:[_posts objectAtIndex:indexPath.row]];



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [tableView deselectRowAtIndexPath:indexPath animated:YES];


[read article]



 self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(reload:)];


class reference



[read article]


This only works for IOS 6, for 5 search in Stack flow. 

First, install button trigger to set global boolean to hide or not. in this example, it is a detailViewManager.


// Connected from button to hide/unhide the master controller this only work on 6.x

// for IOS 5, needs another trick. Also updated splitViewController.shouldHideViewController() in SplitController delegate

- (void)hideUnhide:(id)sender


    NSLog(@"DetailView controller hide/unhide");

    doHideMasterView = !doHideMasterView; // a bool variable


    DetailViewManager *detailViewManager = (DetailViewManager*)self.splitViewController.delegate;


    detailViewManager.hideMaster = !detailViewManager.hideMaster;

    [self.splitViewController.view setNeedsLayout];

    [self.splitViewController willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];


Secondly, need to update shouldHideViewController(). This tells the framework to hide the controller or not. 
keep in mide that the first block would hide the master for portrait by default. the global hide flag only applies when it is landscape mode. 
This should be under spliViewController override. 

// -------------------------------------------------------------------------------

// splitViewController:shouldHideViewController:inOrientation:

// -------------------------------------------------------------------------------

- (BOOL)splitViewController:(UISplitViewController *)svc 

   shouldHideViewController:(UIViewController *)vc 



    return UIInterfaceOrientationIsPortrait(orientation) || hideMaster;



[read article]


have to implement Table data source delegate....... specially


(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


To make a perfect fit and custom size, need to override/implement other methods too in that delegate. 

[read article]


First need regular View Controller, here say PopoverContentViewController 

create instance with it. 


PopoverContentViewController *content = [[PopoverContentViewController alloc] init];


Then assume there is popover controller property in this class



self.detailViewPopover = [[UIPopoverController alloc] initWithContentViewController:content];

self.detailViewPopover.popoverContentSize = CGSizeMake(320., 320.);

self.detailViewPopover.delegate = self;


register self as a PopOverDelegate


two ways to present popover





// Set the sender to a UIButton.

UIButton *tappedButton = (UIButton *)sender;


// Present the popover from the button that was tapped in the detail view.

[self.detailViewPopover presentPopoverFromRect:tappedButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


// Set the sender to a UIBarButtonItem.

UIBarButtonItem *tappedButton = (UIBarButtonItem *)sender;


// If the popover is already showing from the bar button item, dismiss it. Otherwise, present it.

if (self.barButtonItemPopover.popoverVisible == NO) {

[self.barButtonItemPopover presentPopoverFromBarButtonItem:tappedButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


else {

[self.barButtonItemPopover dismissPopoverAnimated:YES];


to dismiss

// If the master list popover is showing, dismiss it before presenting the popover from the bar button item.

if (self.mainPopoverController != nil) {

       [self.mainPopoverController dismissPopoverAnimated:YES];


[read article]



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

- (void)viewDidLoad {

    [super viewDidLoad];


// Add a label to the popover's view controller.

UILabel *popoverLabel = [[UILabel alloc] initWithFrame:CGRectMake(0., 0., 320., 320.)];

popoverLabel.text = @"POP!";

popoverLabel.font = [UIFont boldSystemFontOfSize:100.];

popoverLabel.textAlignment = UITextAlignmentCenter;

popoverLabel.textColor = [UIColor redColor];


[self.view addSubview:popoverLabel];


[read article]



UIButton *tappedButton = (UIButton *)sender;


// remove the current view. This works somehow. TODO do find another way to do.

[self.detailViewPopover.contentViewController.view.subviews[0] removeFromSuperview];


//First init with Frame/size

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0., 0., 320., 320.)];


//set image to new Imageview

[imageView setImage:tappedButton.imageView.image];


[self.detailViewPopover.contentViewController.view addSubview:imageView];

[read article]





AddPersonViewController *controller = [[AddPersonViewController alloc]




[self.navigationController pushViewController:controller



In this example, createa a view Controller and push through nav controller. I dont know how memory is managed with new view created all the time. 



[read article]


This table view will be sub view of self. 


- (void)viewDidLoad{


  [super viewDidLoad];


  self.title = @"Persons";


  self.tableViewPersons = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];

  self.tableViewPersons.delegate = self;

  self.tableViewPersons.dataSource = self;


  [self.view addSubview:self.tableViewPersons];


  self.barButtonAddPerson = [[UIBarButtonItem alloc





  [self.navigationItem setLeftBarButtonItem:[self editButtonItem]



  [self.navigationItem setRightBarButtonItem:self.barButtonAddPerson




[read article]



- (void) setEditing:(BOOL)paramEditing




// call super setEditing in UIViewController

  [super setEditing:paramEditing



//This just showning when editing, hide other buttons on the navigation bar. 

  if (paramEditing){

    [self.navigationItem setRightBarButtonItem:nil


  } else {

    [self.navigationItem setRightBarButtonItem:self.barButtonAddPerson




//Call UITableView setEditing.

  [self.tableViewPersons setEditing:paramEditing








Along with the implementation of the above method, editing involves editBarItemButton. 

Above example had the following line when view initiated.




[self.navigationItem setLeftBarButtonItem:[self editButtonItemanimated:NO];

[read article]


In the story board, custom should be selected and "name" should be given....

Also class name should be entered that created to control. 



#import <UIKit/UIKit.h>


@interface CustomAlienSegue : UIStoryboardSegue




@implementation CustomAlienSegue






See the UIStoryboardSegue class...note that there are sourceControl and destinationViewControl to use. 





@class UIViewController;


NS_CLASS_AVAILABLE_IOS(5_0) @interface UIStoryboardSegue : NSObject


// Convenience constructor for returning a segue that performs a handler block in its -perform method.

+ (id)segueWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination performHandler:(void (^)(void))performHandler NS_AVAILABLE_IOS(6_0);


- (id)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination; // Designated initializer


@property (nonatomic, readonly) NSString *identifier;

@property (nonatomic, readonly) id sourceViewController;

@property (nonatomic, readonly) id destinationViewController;


- (void)perform;







[read article]


To Import Magical Records, need to include in prefix.pch file #Import "CoreData_MagicalRecords.h"

otherwise, will have build error

[read article]





Guide from Apple


[read article]


This is about   NSObject  setValue: forkey

NSObject will raise exception if undefined key is used. In that case, has to override method

setValue:    forUndefinedKey

and do nothing in the method.

[read article]




To trigger to the View redraw.

self setNeedsDisplay()

[read article]


1. Certificates required for application signing and included in provisioning profile.

2. Seprate set of certificates also needed to be submitted for each of development and production of appID bound services like push notifications. 

3. A provisioning profile is a collection of digital entities that uniquely ties developers and devices to an authorized iPhone Development Team and enables a device to be used for testing. A Development Provisioning Profile must be installed on each device on which you wish to run your application code. Each Development Provisioning Profile will contain a set of iPhone Development Certificates, Unique Device Identifiers and an App ID. Devices specified within the provisioning profile can be used for testing only by those individuals whose iPhone Development Certificates are included in the profile. A single device can contain multiple provisioning profiles.

4. Production provisioning profile should be created for app-store submission.

5. Also, if application receives push notification, production provisioning profile should be created with unique AppID.



[read article]