2011-01-13 23 views
0

は、誰かがこのコード行で私の疑いを確認することができます。基本Objective Cの構文質問

NSUInteger newPath[] = {[indexPath section],0}; 

私はそれがNSUIntegersのC配列だと確信しています。 私はこれについて正しいですか? は、あなたも、Objective CのオブジェクトのC配列を作ることはできますか?ここ

は、コンテキスト内のコードである:

-(UITableViewCellEditingStyle)tableView:(UITableView *) tableViewEditingStyleForRowAtIndexPath:(NSIndexPath*)indexPath{ 

if ([self isToManyRelationshipSection:[indexPath section]]) { 
    NSUInteger newPath[] = {[indexPath section],0}; 
    NSIndexPath *row0IndexPath = [NSIndexPath indexPathWithIndexes:newPath length:2]; 

    NSString *rowKey = [rowKeys nestedObjectAtIndexPath:row0IndexPath]; 
    NSString *rowLabel = [rowLabels nestedObjectAtIndexPath:row0IndexPath]; 
    NSMutableSet *rowSet = [managedObject mutableSetValueForKey:rowKey];//!!!: to-many? 
    NSArray *rowArray = [NSArray arrayByOrderingSet:rowSet byKey:rowLabel ascending:YES]; 

    if ([indexPath row] >= [rowArray count]) { 
     return UITableViewCellEditingStyleInsert; 
    } 

    return UITableViewCellEditingStyleDelete; 
} 
return UITableViewCellEditingStyleNone; 
+1

NSUIntegerは、ここで定義されたオブジェクト、その交流タイプを、イマイチ/Reference/reference.html#//apple_ref/doc/uid/20000018-SW71 –

+0

ニース、私は気付きませんでした。だから、それは動的な基本的なタイプです。 NSUIntegerは32ビットの符号なし整数で、64ビットアプリケーションはNSUIntegerを64ビットの符号なし整数として扱います。 " – Aaronium112

答えて

3

はい、あなたは正しいです。しかし...

NSUInteger newPath[] = {[indexPath section],0}; 
NSIndexPath *row0IndexPath = [NSIndexPath indexPathWithIndexes:newPath length:2]; 

私は強くをうがUITableViewでの使用を意図していますNSIndexPathを作成するには、このフォーマットを使用してからあなたを落胆します。 There's a convenience method to do thisずっとより簡単に:http://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes:

NSIndexPath *row0IndexPath = [NSIndexPath indexPathForRow:0 inSection:[indexPath section]]; 
0

NSUIntegerは、Objective-Cのオブジェクトではありません。これは、符号なし整数のtypedefです。使用しているプラ​​ットフォームによっては、intまたはlongである可能性があります。しかし、それは目的ではありません。だから、基本的にintのc配列を持っています。

3

私はそれがNSUIntegersのC配列だと確信しています。私はこれについて正しいですか?

うん、それは確かです。

あなたも、Objective CのオブジェクトのC配列を作ることはできますか?

できます。たとえば、これは2つの配列ですNSString *

NSString *myStrings[] = {@"one", @"two"}; 

これは役に立ちますか?時には、オブジェクトの配列が必要な場合は、NSArrayを使用することがほとんど常に有益です。

+0

偉大な答えです。ありがとうございました。 – Aaronium112

+0

@MakingScienceFictionFactそのような偉大な答えなら、あなたは答えの横のチェックをクリックすることをお勧めします:) –