Wednesday, June 29, 2011

Integrating C++ files with Objective-C (tips)

This trick will be helpful for people who are trying to embed Opengl ES code in their iPhone project.
One way to let your compiler know that you will be using mix of C++ and objective-C will be to convert the extension of all .m files to .mm as discussed in one the previous post(LINK) but there is another way if you don't want to change all the extensions  !


In your project Settings, Under Build Settings > GCC 4.2- Language
Change the "Compile Source As" value to "Objective-C++"
































It will let you compile the code without changing the extensions of all the files.

I found this wonderful tip from Pete Cole blog. LINK

Tuesday, June 28, 2011

Expected specifier-qualifier-list error in OpenGL ES iPhone project.

Well. Team was trying to create this first OpenGL ES code following the instructions of Chapter 1 in iPhone 3D Programming by Philip Rideout, and faced problem of specifier-qualifier-list in my .hpp file.
Well, to fix this problem do following:

1. Changed all .m in my project to .mm

Hope it helps someone facing the same problem.

Monday, June 27, 2011

Face Detection API in iOS 5.

CoreImage framework introduced in iOS 5 API has  classes called CIFaceFeature  and CIDetector.This class has potentially has been added for detecting face feature in the image. Currently, it offers following functionalities:








CIDetector has ability to detect face as a whole.
If you are wondering how to add framework in your project, refer to this post. LINK

How To Activate Split Keyboard on iPad

You need iOS 5 for this.To activate Split Keyboard on iPad, find and long press the keyboard icon at the bottom right of the keyboard.This will give you 2 options: undock and split. With undock you can set the keyboard higher or lower on the screen. With split, you can split the keyboard.



Sunday, June 26, 2011

How to commit changes to your project on github?

Ok. So in our last post we saw how we can upload our fresh project on Github. LINK

If you have not set up your github on your mac yet. Here is the link to do so which is its official page. I followed the same :)
LINK



In this article, we are going to see how we can commit new changes in our project.

Conventions are same: Highlighted lines were written by me and Comments for the steps are written within /* */ and non-highlighted lines are the system responses.

/*We are going to add upstream support in our local Github repo*/

Reetu-Rajs-MacBook:Template1 reeturaj$ git remote add upstream git://github.com/ReetuRaj/MIMSlideShow.git


Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git fetch upstream

/*This command will tell you if you have any new files or any modified files  in your repo. Here you can see ReadMe is the modified file available which needs to be committed on remote Github repo.*/

Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git commit -m "commit 1.1"

# On branch master
# Changed but not updated:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
# modified:   README
#
no changes added to commit (use "git add" and/or "git commit -a")

/*This command will actually open VIM editor and will ask you to enter the commit remark.Once you done with writing your remark, you can press ESC  then :wq to exit out of VIM editor.*/
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git commit -a

[master 1e1fd23] Test Commit
 3 files changed, 4532 insertions(+), 4538 deletions(-)
/*This command will  push all the latest changes on remote Github repo.*/
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git push origin master

Counting objects: 19, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (10/10), 7.05 KiB, done.
Total 10 (delta 4), reused 0 (delta 0)
To git@github.com:ReetuRaj/MIMSlideShow.git
   3ef6aac..1e1fd23  master -> master




CASE 2:

As shown in above lines you can find how many files were modified or added by following command:
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git commit -m "commit 1.1"


If you see that new files were added, you will get following for the files which are new and not available on the remote Github repo. In my case, README file is not yet present on remote Github repo but its present on my local Github repo. So obviously I want to add it on my remote repo.

# On branch master
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
# README
nothing added to commit but untracked files present (use "git add" to track)

/*So I will  just run add . command to add all new files , Note the dot(.) after add*/
Reetu-Rajs-MacBook:Template1 reeturaj$ git add .

/*Then our usual commit followed by push command*/
Reetu-Rajs-MacBook:Template1 reeturaj$ git commit -a

[master 7f8db7e] Adding a README file
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 README

Reetu-Rajs-MacBook:Template1 reeturaj$ git push origin master
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 465 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)


DONE !  :)


HOW TO DELETE A REPO FROM GITHUB

How to upload fresh project on github?


If you have not set up your github on your mac yet. Here is the link to do so which is its official page. I followed the same :)
LINK


Well.. After I followed all the steps on github like created a repository, added the ssh key etc as described in the set up link I provided above.

Now the time comes for me to upload my project on github.

So, my project is in Home/Documents/MIMSlideShow/
I navigate to that directory and then created a local git repository and pushed my project on the remote MIMSlideShow folder.The highlighted lines were written by me and non-highlighted lines are the system messages.




Reetu-Rajs-MacBook:~ reeturaj$ ls
Apple Sample Codes Library Public
Desktop Movies RootPasswd.rtf
Documents Music Sites
Downloads Pictures Softwares
Reetu-Rajs-MacBook:~ reeturaj$ cd Documents/MIMSlideShow/
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git init
Initialized empty Git repository in /Users/reeturaj/Documents/MIMSlideShow/.git/
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git add .
NOTE: add[space]. Otherwise you will get warning !
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git commit -m "Initial commit"
[master 3ef6aac] Initial commit
 40 files changed, 11851 insertions(+), 0 deletions(-)
 create mode 100644 MIMSlideShow.xcodeproj/project.pbxproj
 create mode 100644 MIMSlideShow.xcodeproj/project.xcworkspace/contents.xcworkspacedata
 create mode 100644 MIMSlideShow.xcodeproj/project.xcworkspace/xcuserdata/reeturaj.xcuserdatad/UserInterfaceState.xcuserstate
 create mode 100644 MIMSlideShow.xcodeproj/xcuserdata/reeturaj.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
 create mode 100644 MIMSlideShow.xcodeproj/xcuserdata/reeturaj.xcuserdatad/xcschemes/MIMSlideShow.xcscheme
 create mode 100644 MIMSlideShow.xcodeproj/xcuserdata/reeturaj.xcuserdatad/xcschemes/xcschememanagement.plist
 create mode 100644 MIMSlideShow/1.jpg
 create mode 100644 MIMSlideShow/10.jpg
 create mode 100644 MIMSlideShow/11.jpg
 create mode 100644 MIMSlideShow/12.jpg
 create mode 100644 MIMSlideShow/13.jpg
 create mode 100644 MIMSlideShow/14.jpg
 create mode 100644 MIMSlideShow/15.jpg
 create mode 100644 MIMSlideShow/16.jpg
 create mode 100644 MIMSlideShow/2.jpg
 create mode 100644 MIMSlideShow/3.jpg
 create mode 100644 MIMSlideShow/4.jpg
 create mode 100644 MIMSlideShow/5.jpg
 create mode 100644 MIMSlideShow/6.jpg
 create mode 100644 MIMSlideShow/7.jpg
 create mode 100644 MIMSlideShow/8.jpg
 create mode 100644 MIMSlideShow/9.jpg
 create mode 100644 MIMSlideShow/Global.h
 create mode 100644 MIMSlideShow/MIMLayer1.h
 create mode 100644 MIMSlideShow/MIMLayer1.m
 create mode 100644 MIMSlideShow/MIMLayer2.h
 create mode 100644 MIMSlideShow/MIMLayer2.m
 create mode 100644 MIMSlideShow/MIMSlideShow-Info.plist
 create mode 100644 MIMSlideShow/MIMSlideShow-Prefix.pch
 create mode 100644 MIMSlideShow/MIMSlideShowAppDelegate.h
 create mode 100644 MIMSlideShow/MIMSlideShowAppDelegate.m
 create mode 100644 MIMSlideShow/MIMSlideShowTemplate1.h
 create mode 100644 MIMSlideShow/MIMSlideShowTemplate1.m
 create mode 100644 MIMSlideShow/MainViewController.h
 create mode 100644 MIMSlideShow/MainViewController.m
 create mode 100644 MIMSlideShow/MainViewController.xib
 create mode 100644 MIMSlideShow/en.lproj/InfoPlist.strings
 create mode 100644 MIMSlideShow/en.lproj/MainWindow.xib
 create mode 100644 MIMSlideShow/main.m
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git remote add origin git@github.com:ReetuRaj/MIMSlideShow.git

Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git push origin master
Counting objects: 54, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (52/52), 4.52 MiB | 38 KiB/s, done.
Total 52 (delta 4), reused 0 (delta 0)
To git@github.com:ReetuRaj/MIMSlideShow.git
   1f5162a..3ef6aac  master -> master


Thats it ! Project was there  on my github MIMSlideshow repository !

Note: How did I get git@github.com:ReetuRaj/MIMSlideShow.git ?
Well for your own project it will be different string. You can find it on your project page as shown in the screenshot below:











Next thing useful for you could be ARTICLE: How to commit changes to your project on github?










NOTE: Recently, while adding a new project to Github, I was getting following error



git remote add origin git@github.com:Reetu/MIMChartLib.git
fatal: remote origin already exists.




So following command removed the error
$ git remote rm origin

How to Link your Facebook page with your twitter account ?

Well.. today I was reminded by someone that I have a FB Page too ! so I thought lets make use of it. And As my blog and twitter are already connected. Lets just connect the FB page to it as well !

Here is the Twitter widget which lets you do that ! LINK

There was this really nice article which helped me find it  by AJ Vaynerchuk. LINK

Installing Github on MacOSX

Ok. After delaying the process for so many days, I decided to just do this task pending on my to-do list !
Now on, all my opensource projects/codes will be available on github repositories !
I have been constantly  getting hit by new ideas to do and my to-do list is just getting bigger day by day ! :)
So more articles will  be arriving on blog :)

Anyways. If you want to set up your github too. Here is the link to do so which is its official page. I followed the same :)

LINK


Note: After you follow steps on link above , if you are new then following are 2 topics are not specified in the link above. You can find them in following articles:

ARTICLE 1: How to upload fresh project on github?


ARTICLE 2: How to commit changes to your project on github?



There is a good news. I am trying to work on this opengl ES  tutorial series which is loosely based on the legendary NeHe opengl tutorial series. I will be following kind of same topics but in opengl ES :) Also going to put all the tutorial source code on the github. I have been getting constant emails about how the basic codes in my articles which I have uploaded so far have been helping people in getting things going. I am really really glad that I could be useful for the coder community.



Friday, June 24, 2011

Convert NSString to NSDate

This is helpful when say,

1. You want to compare 2 dates and your dates were stored as string , now in order to be able to compare them you have to convert them back to NSDate.

OR

2. You want to convert your Date String format so you want to convert your date string to date then user NSDateFormatter to display it in the required format.

You can do following:

       NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"MM-dd-yyyy HH:mm "];
    NSDate* date = [formatter dateFromString:@"07-17-2012 15:20"];
    NSLog(@"%@", date); 
    // Note this prints date and time of another 
    //timezone because we didnt define it in our NSDateFormatter
    
    
    //Now convert it into another format
    formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"EEEE\n MMMM dd,yyyy HH:mm "];
    NSString *_strD=[formatter stringFromDate:date];
     NSLog(@"_strD=%@", _strD);



Original format of given date was 07-17-2012 15:20 and this code prints final date in following format:


Tuesday
July 17,2012 15:20 


On a different note, if you have 2 dates and you want to compare them you can use following:


    // Create date of your choice 
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"MM-dd-yyyy HH:mm "];
    NSDate* date = [formatter dateFromString:@"07-17-2012 15:20"];    
    
    //Lets get today's date
    NSDate *today=[NSDate date];

    //compare today's date with the date of our choice
    NSInteger compareResult= [date compare:today];
    NSLog(@"compareResult=%d", compareResult);
    
    NSInteger compareResultMore= [today compare:date];
    NSLog(@"compareResultMore=%d", compareResultMore);


compareResult is = 1 if NSDate date  comes after NSDate today otherwise it will be -1.

Convert NSDate to NSString.

You will have to use NSDateFormatter in order to be able to convert the NSDate to NSString.
Following article explains it. LINK

Then if you are dealing with timeintervals, following article(LINK) can be helpful.

Tuesday, June 21, 2011

Opensource View Transition Library - Update

LINK to the previous effects.

Here are screenshots of the 3 more new effects added.

Door with Teeth Closing In
Elliptical-Ease Out
Elliptical Reveal Ease In



LINK TO REPOSITORY

Opensource View Transition Library.

Effects as shown below have been included in this library. There many more effects I am working on. I will keep releasing as I finish.









LINK TO THE REPOSITORY

Monday, June 20, 2011

Horizontal flip in CGontextRef.

If you want to do the mirror image of the CGContext, then you want to do the horizontal flip. Use following 2 lines of code:


CGAffineTransform transform = CGAffineTransformMake(-1.0, 0.0, 0.0, 1.0, widthOfScreen, 0.0);
CGContextConcatCTM(context,transform);



For vertical flip, follow this article: LINK

New transition Effects for Slideshow.- Part 4

Effect 1
Effect 2
Effect 3


Here is latest transition effect screenshots.
 

New transition Effects for Slideshow.- Part 3

Links to previous effects:

Effect 1
Effect 2



Here are the screenshots of the Effect 3


 




  



Sunday, June 19, 2011

New Transition Effects for Slideshow.- Part 2

Here is a link to article which talks about effect 1.
Screenshots as usual of the progression of the slideshow in play.






New Transition Effects for Slideshow.

For everything there is some inspiration, I was looking at those cool transition effects available on .ppt in Microsoft Powerpoint  software , so I thought may be I should write some of my own transitions effects which can be easily applied for creating a cool effect in slideshow on an app.
Here are some screenshots of the first transition effect I have written.





Vertical flip in CGontextRef.

Vertical Flip- which means top to down.

If you try to draw an image on CGContextRef , it will appear upside down, you will have to apply transformation on it set it right.Make sure you add QuartzCore.
 #import


1. Drawing an image on CGContextRef without transformation

CGContextRef context=UIGraphicsGetCurrentContext();
CGContextDrawImage(context, CGRectMake(0, 0, 768, 1024), [UIImage imageNamed:@"1.jpg"].CGImage);













2. Drawing an image on CGContextRef with transformation of vertical flip

CGContextRef context=UIGraphicsGetCurrentContext();
CGAffineTransform flipTransform = CGAffineTransformMake( 1, 0, 0, -1, 0, self.frame.size.height);
CGContextConcatCTM(context, flipTransform);
CGContextDrawImage(context, CGRectMake(0, 0, 768, 1024), [UIImage imageNamed:@"1.jpg"].CGImage);









For horizontal flip, you can read this article : LINK

Friday, June 17, 2011

Add Image in iPad Simulator.

You can do it very well  by using Safari !!!


1. If you want to transfer your photos which you have gather over  the time to your iPad Simulator.Then easiest way it to Open the Safari on iPad Simulator. Drag and drop that image on Simulator, it will open the image on Safari on Simulator. Long Press on it will ask you Save or Copy. You simple press Save.
Then you go to your Photos application of iPad. And you will be able to find your recently added photos in there !!

2. You can directly download the images from web. Open the desired webpage on Safari on iPad simulator. Long press on image of webpage which you would like to save. It will give option to Save the image, so you save it ! You will find that image in Photos application of your Simulator.




Drag and drop the image shows in Safari browser.





Long press on image shows the option to save or copy.

Photos Application on Simulator displays the image saved by you.

iOS Rich Text Editor Color Picker
























Here is the update. I have created a color picker which user can use to choose the color of his text. It looks ok but oh well, I am here to create some features. Don't care much about UI right now. May be if some UI designer gets to read this post, he/she can help me.




iOS Rich Text Editor Update

Well. I have been digging around a lot. And  in order  to have my own customized select text feature I will be doing a post-mortem of a linux text editor written in C to get an idea of the libraries which will be used to do in the meanwhile for today I will just release the color picker for the  rich text editor.

Thursday, June 16, 2011

Copy items of NSMutableArray into another ?

Lets say you have arrayA and arrayB, arrayB could be NSArray or NSMutableArray.
But arrayA should be mutable.


  [arrayA addObjectsFromArray:arrayB];





Here you are copying items from  arrayB to arrayA. Make sure you have already alloc memory for arrayA as:

arrayA = [[NSMutableArray alloc]init];




Case 2: If you want to create a copy an array to NSArray, you can do so as following:

NSArray *db=[[NSArray alloc]initWithArray:availListArray];



How to find target audience on Twitter ?




I have recently been haunted by the universal question of how to reach people.  And reach right people. The people who will be really interested to know what you write about. For software developers.. they only google when they want to find out a particular programming related problems. Well as I don't have any sponsor to help me with advertising. Well I don't know if would like to spend on advertisement as I want it to be more real process. Like if some people like my blog because of its content then they will refer it to their friends.
But I think twitter is a great way to reach your audience as it keeps it short through microblogging so with just few words and time you can figure out whether you want to follow a person or not I was searching about it and I found this wonderful article by Lisa Orrell.
She has written good about resources which can help you achieve it. She has talked about

Twitter Search
http://search.twitter.com/

and

Twellow
http://www.twellow.com/


 LINK TO HER ARTICLE

There is another article from Swati Ramnath which talks about same topic, its a good read. LINK TO HER ARTICLE

Wednesday, June 15, 2011

How to create UILabel with multi color in iPhone ?





















Unfortunately, bottom line is that you can't do that  in UILabel. Either you gotta use UIWebView or you gotta use CoreText frame work. HERE is my tutorial for CoreText beginners hope it helps you to create the Text Labels with multiple color. Comment me or email me in case of any questions.


Status of Rich Text Editing on iPad


Well.  I was just goofing around on web when I found there is no native API on iOS which lets you create rich text editor while its available for mac SDK.
I looked around a lot whether there are any  libraries budding up . There is one called OMNI group rich text library, they have done a good job. They are developing more features in it.
There are people countable on finger who have actually talked about this on their blog. One blog is really recommendable. They have have been able to create the multi colored text along with the pointer. LINK TO ARTICLE.
There is a new app launched recently called  Essay which is a rich text editor for iOS, but sadly there aren't very great reviews about it either. I haven't used it myself to I have to depend on the opinion of the reviewers.And also its not open source so its of no help to other developers. LINK TO ARTICLE.

And So I decided to take a plunge myself and see what good I can come up with.
Check out THIS POST of mine. I have been able to do some work on it.

iOS Rich Text Editor

I recently posted an article about existing status of  Rich Text Editor APIs/Rich Text Editor Apps for iOS  HERE.

This is the article about my own iOS Rich Text Editor . I am going to name my little Rich Text Editor as MIM Text Editor.

So here is the first update. I am planning to release the open source API quickly before Apple's releases the iOS 5 in market.  My goal will be to make it really really easier for developers to use it. Just like Apple's way . Keep it simple !Developers will be able to just stick it into their application and it will be ready to go.

I have taken up a really huge project in my hand I know.. there are so many things which are possible in a rich text editor.. but a step further every day I am going to keep updating on this blog. And of course other interesting resources which I come across will be posted too ! :)

Screenshots of First Update are attached below. I know it sucks but these are the features I have just finished or they are being worked on for API release!  And all this I have come up with in few hours of work today so I guess its a good start !

Features I can have finished:

1. Write alphabets
2. Delete alphabets
3. Change Font
4. Change FontSize
5. Clear All Text on the editor Pad.
6. Change Color (Right now it just displays the standard Color, I want to do it more like Apple's color picker)
7. Keyboard Appears and Disappears  on user driven event.
8. Pointer


Here are the few screenshots



Screenshot which shows text in another font
 Here is the LINK to the post which mentions how to get the font family array for iOS






Screenshot of text with changed font size.

Newly added pointer feature.

Font family in iOS

Here is the little code snippet which lets you get the array of font family available on iOS.

       NSString *family;
    for (family in [UIFont familyNames])
    {
    //  you can print family string or do whatever you want with it.
    }

NSUserDefaults Example Code



NSUserDefaults is generally used for storing information of an app with in application's sandbox. It comes very handy when you want to store very small amount of information. Like if you have a login screen and you want to store the username and password for next login for user's convenience, then its best to use NSUserDefaults ! I am going to tell you how you can do it.




First you need to create an instance of NSUserDefault in your code




NSUserDefaults *userDefaults=[NSUserDefaults standardUserDefaults];


Then you can save data of various kinds as shown following:






This lets you save an integer as NSNumber for key IndexForZ


[userDefaults setObject:[NSNumber numberWithInt:myInteger] forKey:@"IndexForZ"];






You can save a string as following


[userDefaults setObject:@"Reetu" forKey:@"name"];




Following methods let you save as they: Integer, float, double, bool and url respectively !


- (void)setInteger:(NSInteger)value forKey:(NSString *)defaultName;



This could be used as:


[userDefaults setInteger:1 forKey:@"rank"];


Other methods available in the iOS SDK are:


- (void)setFloat:(float)value forKey:(NSString *)defaultName;
- (void)setDouble:(double)value forKey:(NSString *)defaultName;
- (void)setBool:(BOOL)value forKey:(NSString *)defaultName;
- (void)setURL:(NSURL *)url forKey:(NSString *)defaultName;

To retrieve the values from these keys in NSUserDefaults anywhere in your application , on any view controller... you can just again create an instance of NSUserDefaults and use stringForKey or integerForKey


NSUserDefaults *userDefaults=[NSUserDefaults standardUserDefaults];
NSString *nameVal=[userDefaults stringForKey:@"name"];
NSInteger rank =[userDefaults integerForKey:@"rank"];

Tuesday, June 14, 2011

How to create ad-hoc distribution file on XCode 4 ?

I found these 2 articles of good value. Enjoy them.
Basically they tell you how you can create .ipa file which is result of your ad hoc distribution build. These .ipa files you can drag and drop into your iTunes and sync.



http://diaryofacodemonkey.ruprect.com/2011/03/18/ad-hoc-app-distribution-with-xcode-4/


and


http://www.musicalgeometry.com/?p=1237



If you want to know how you want to create  a distribution build to submit to App Store then REFER To THIS POST of mine.

How to create Pencil tool OR Pen Tool in iPhone/iPad?

There have been  requests  to write about Pencil Tool, Pen Tool.
I guess THIS POST will help.

Create UIView with nib file in XCode 4 : Tutorial

Ok, this post talks about how you go about creating UIView with nib files and load them. Sometimes people have queries about it.. So I thought it will be cool to write about it.


1. You add new files in your project.

























2. As usual, you select  objective-C class to create a UIView.
























3. You choose UIView
























4.Pressing next will popup another window where you enter name of your UIView subclass. I named it MIMSearchStringTable.
























5. After you press Save, you will view new UIView subclass files created in the project.
























6. Now you add a nib file. Add new file in your project You choose User Interface > Empty
























7. Choose whether it will be for iPhone or iPad.
























8. Give the name of you nib file same as your UIView subclass files. I name them same as MIMSearchStringTable  and Save.
























9. Now I drag a "View"  element on the right panel to my drawing area(square check area).

10. Press File's Owner as shown below. In right panel we have to set its owner. So under Custom Class, you see Class saying NSObject. We have to change it. Click on it and it will display the tableview with options available.

























11. We have to make MIMSearchStringTable class as it owner. Hence we choose it.


12. Now you just go to your .m file and load nib file you just created by writing 2 lines as described in this POST HERE . They are same as shown below but you can copy them easily from my post whose link I have provided.Make sure you put the name in front of loadNibNamed: same as  your nib file name.

























13. Now we gotta put some UI elements in our nib file. I want to put a tableview. Hence I will make an IBOutlet in my .h file.


























14. I go to my nib file where I had dropped the View Element from right panel. Now its time to drag and drop the TableView element from the right panel.

























15. I can resize the Tableview. as well as my View.

























16. As you can see here, I resized my View as well as its child TableView.


























17. Now I make the connection as following.

























18.After connection is made you will be able see that Table View is connected to IBOutlet I created in my .h file earlier.

























19. Now I need to set my delegates and datasource for the TableView. Hence I selected the TableView by tapping on it gently in View.


























20. On the right panel. I have to connect the datasource and delegate to File's Owner. I did this only because I am connecting UITableView. You will know it if you have experience of doing IB connections already.



























21. You can change the rowHeight of the cell as shown below. Well your rows will appear short in height  depends on your requirement if you need to set it or not.


























And write your tableview delegate and datasource methods. Important ones are :


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;