Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert NSIndexpath into NSInteger or simply int?

I need to convert a nsindexpath var into NsInteger or simply an int. e.g:

 int rowIndex = [mGoogleBaseTable selectedRow];
 //mGoogleBaseTable is a NSTable type in Macdevelopement..

&&

int rowIndex = [mGoogleBaseTable indexPathForSelectedRow];
//mGoogleBaseTable is a UITableView type in Iphone (iOS)Development.

selectedRow returns NSInteger simply but indexPathForSelectedRow returns a NSIndexPath..

Please help me how can i achieve this.

like image 863
Tarun Avatar asked Jan 01 '11 15:01

Tarun


3 Answers

If

NSIndexPath *p = ... // some indexpath

then

NSInteger row = p.row;
NSInteger section = p.section;

That's all!

like image 127
mvds Avatar answered Nov 17 '22 14:11

mvds


Maybe, this is can help you

NSInteger variable = indexPath.row;
like image 14
PS.OHM Avatar answered Nov 17 '22 14:11

PS.OHM


In Swift:

    let section: Int = indexPath.section
    let row: Int = indexPath.row
like image 8
King-Wizard Avatar answered Nov 17 '22 13:11

King-Wizard