Просмотр исходного кода

use Objective-C 2.0 subscripting for arrays

Dan Loewenherz лет назад: 10
Родитель
Сommit
08b25ea8d3

+ 3 - 3
Classes/Editing/ArgumentInputViews/FLEXArgumentInputStructView.m

@@ -31,7 +31,7 @@
             inputView.targetSize = FLEXArgumentInputViewSizeSmall;
             
             if (fieldIndex < [customTitles count]) {
-                inputView.title = [customTitles objectAtIndex:fieldIndex];
+                inputView.title = customTitles[fieldIndex];
             } else {
                 inputView.title = [NSString stringWithFormat:@"%@ field %lu (%@)", structName, (unsigned long)fieldIndex, prettyTypeEncoding];
             }
@@ -72,7 +72,7 @@
                 [FLEXRuntimeUtility enumerateTypesInStructEncoding:structTypeEncoding usingBlock:^(NSString *structName, const char *fieldTypeEncoding, NSString *prettyTypeEncoding, NSUInteger fieldIndex, NSUInteger fieldOffset) {
                     
                     void *fieldPointer = unboxedValue + fieldOffset;
-                    FLEXArgumentInputView *inputView = [self.argumentInputViews objectAtIndex:fieldIndex];
+                    FLEXArgumentInputView *inputView = self.argumentInputViews[fieldIndex];
                     
                     if (fieldTypeEncoding[0] == @encode(id)[0] || fieldTypeEncoding[0] == @encode(Class)[0]) {
                         inputView.inputValue = (__bridge id)fieldPointer;
@@ -102,7 +102,7 @@
         [FLEXRuntimeUtility enumerateTypesInStructEncoding:structTypeEncoding usingBlock:^(NSString *structName, const char *fieldTypeEncoding, NSString *prettyTypeEncoding, NSUInteger fieldIndex, NSUInteger fieldOffset) {
             
             void *fieldPointer = unboxedStruct + fieldOffset;
-            FLEXArgumentInputView *inputView = [self.argumentInputViews objectAtIndex:fieldIndex];
+            FLEXArgumentInputView *inputView = self.argumentInputViews[fieldIndex];
             
             if (fieldTypeEncoding[0] == @encode(id)[0] || fieldTypeEncoding[0] == @encode(Class)[0]) {
                 // Object fields

+ 1 - 1
Classes/ExplorerToolbar/FLEXExplorerViewController.m

@@ -331,7 +331,7 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 {
     NSUInteger indexOfView = [self.viewsAtTapPoint indexOfObject:object];
     if (indexOfView != NSNotFound) {
-        UIView *view = [self.viewsAtTapPoint objectAtIndex:indexOfView];
+        UIView *view = self.viewsAtTapPoint[indexOfView];
         NSValue *key = [NSValue valueWithNonretainedObject:view];
         UIView *outline = [self.outlineViewsForVisibleViews objectForKey:key];
         if (outline) {

+ 1 - 1
Classes/GlobalStateExplorers/FLEXClassesTableViewController.m

@@ -131,7 +131,7 @@
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
-    NSString *className = [self.filteredClassNames objectAtIndex:indexPath.row];
+    NSString *className = self.filteredClassNames[indexPath.row];
     Class selectedClass = objc_getClass([className UTF8String]);
     FLEXObjectExplorerViewController *objectExplorer = [FLEXObjectExplorerFactory explorerViewControllerForObject:selectedClass];
     [self.navigationController pushViewController:objectExplorer animated:YES];

+ 8 - 8
Classes/GlobalStateExplorers/FLEXFileBrowserTableViewController.m

@@ -171,10 +171,10 @@
 {
     NSString *fullPath = nil;
     if (tableView == self.tableView) {
-        NSString *subpath = [self.childPaths objectAtIndex:indexPath.row];
+        NSString *subpath = self.childPaths[indexPath.row];
         fullPath = [self.path stringByAppendingPathComponent:subpath];
     } else {
-        fullPath = [self.searchPaths objectAtIndex:indexPath.row];
+        fullPath = self.searchPaths[indexPath.row];
     }
     
     NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:fullPath error:NULL];
@@ -221,10 +221,10 @@
     NSString *fullPath = nil;
     
     if (tableView == self.tableView) {
-        subpath = [self.childPaths objectAtIndex:indexPath.row];
+        subpath = self.childPaths[indexPath.row];
         fullPath = [self.path stringByAppendingPathComponent:subpath];
     } else {
-        fullPath = [self.searchPaths objectAtIndex:indexPath.row];
+        fullPath = self.searchPaths[indexPath.row];
         subpath = [fullPath lastPathComponent];
     }
     
@@ -313,11 +313,11 @@
 
     NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
     if (indexPath) {
-        NSString *subpath = [self.childPaths objectAtIndex:indexPath.row];
+        NSString *subpath = self.childPaths[indexPath.row];
         fullPath = [self.path stringByAppendingPathComponent:subpath];
     } else {
         indexPath = [self.searchController.searchResultsTableView indexPathForCell:sender];
-        fullPath = [self.searchPaths objectAtIndex:indexPath.row];
+        fullPath = self.searchPaths[indexPath.row];
     }
 
     self.fileOperationController = [[FLEXFileBrowserFileRenameOperationController alloc] initWithPath:fullPath];
@@ -331,11 +331,11 @@
 
     NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
     if (indexPath) {
-        NSString *subpath = [self.childPaths objectAtIndex:indexPath.row];
+        NSString *subpath = self.childPaths[indexPath.row];
         fullPath = [self.path stringByAppendingPathComponent:subpath];
     } else {
         indexPath = [self.searchController.searchResultsTableView indexPathForCell:sender];
-        fullPath = [self.searchPaths objectAtIndex:indexPath.row];
+        fullPath = self.searchPaths[indexPath.row];
     }
 
     self.fileOperationController = [[FLEXFileBrowserFileDeleteOperationController alloc] initWithPath:fullPath];

+ 3 - 3
Classes/GlobalStateExplorers/FLEXInstancesTableViewController.m

@@ -100,10 +100,10 @@
         cell.detailTextLabel.textColor = [UIColor grayColor];
     }
     
-    id instance = [self.instances objectAtIndex:indexPath.row];
+    id instance = self.instances[indexPath.row];
     NSString *title = nil;
     if ((NSInteger)[self.fieldNames count] > indexPath.row) {
-        title = [NSString stringWithFormat:@"%@ %@", NSStringFromClass(object_getClass(instance)), [self.fieldNames objectAtIndex:indexPath.row]];
+        title = [NSString stringWithFormat:@"%@ %@", NSStringFromClass(object_getClass(instance)), self.fieldNames[indexPath.row]];
     } else {
         title = [NSString stringWithFormat:@"%@ %p", NSStringFromClass(object_getClass(instance)), instance];
     }
@@ -118,7 +118,7 @@
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
-    id instance = [self.instances objectAtIndex:indexPath.row];
+    id instance = self.instances[indexPath.row];
     FLEXObjectExplorerViewController *drillInViewController = [FLEXObjectExplorerFactory explorerViewControllerForObject:instance];
     [self.navigationController pushViewController:drillInViewController animated:YES];
 }

+ 1 - 1
Classes/GlobalStateExplorers/FLEXLiveObjectsTableViewController.m

@@ -200,7 +200,7 @@ static const NSInteger kFLEXLiveObjectsSortByCountIndex = 1;
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
-    NSString *className = [self.filteredClassNames objectAtIndex:indexPath.row];
+    NSString *className = self.filteredClassNames[indexPath.row];
     FLEXInstancesTableViewController *instancesViewController = [FLEXInstancesTableViewController instancesTableViewControllerForClassName:className];
     [self.navigationController pushViewController:instancesViewController animated:YES];
 }

+ 6 - 6
Classes/GlobalStateExplorers/SystemLog/FLEXSystemLogTableViewController.m

@@ -121,10 +121,10 @@
 {
     FLEXSystemLogTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kFLEXSystemLogTableViewCellIdentifier forIndexPath:indexPath];
     if (tableView == self.tableView) {
-        cell.logMessage = [self.logMessages objectAtIndex:indexPath.row];
+        cell.logMessage = self.logMessages[indexPath.row];
         cell.highlightedText = nil;
     } else if (tableView == self.searchController.searchResultsTableView) {
-        cell.logMessage = [self.filteredLogMessages objectAtIndex:indexPath.row];
+        cell.logMessage = self.filteredLogMessages[indexPath.row];
         cell.highlightedText = self.searchController.searchBar.text;
     }
     if (indexPath.row % 2 == 0) {
@@ -140,9 +140,9 @@
 {
     FLEXSystemLogMessage *logMessage = nil;
     if (tableView == self.tableView) {
-        logMessage = [self.logMessages objectAtIndex:indexPath.row];
+        logMessage = self.logMessages[indexPath.row];
     } else if (tableView == self.searchController.searchResultsTableView) {
-        logMessage = [self.filteredLogMessages objectAtIndex:indexPath.row];
+        logMessage = self.filteredLogMessages[indexPath.row];
     }
     return [FLEXSystemLogTableViewCell preferredHeightForLogMessage:logMessage inWidth:self.tableView.bounds.size.width];
 }
@@ -164,9 +164,9 @@
     if (action == @selector(copy:)) {
         FLEXSystemLogMessage *logMessage = nil;
         if (tableView == self.tableView) {
-            logMessage = [self.logMessages objectAtIndex:indexPath.row];
+            logMessage = self.logMessages[indexPath.row];
         } else if (tableView == self.searchController.searchResultsTableView) {
-            logMessage = [self.filteredLogMessages objectAtIndex:indexPath.row];
+            logMessage = self.filteredLogMessages[indexPath.row];
         }
 
         NSString *stringToCopy = [FLEXSystemLogTableViewCell displayedTextForLogMessage:logMessage] ?: @"";

+ 2 - 2
Classes/Network/FLEXNetworkHistoryTableViewController.m

@@ -337,9 +337,9 @@
 {
     FLEXNetworkTransaction *transaction = nil;
     if (tableView == self.tableView) {
-        transaction = [self.networkTransactions objectAtIndex:indexPath.row];
+        transaction = self.networkTransactions[indexPath.row];
     } else if (tableView == self.searchController.searchResultsTableView) {
-        transaction = [self.filteredNetworkTransactions objectAtIndex:indexPath.row];
+        transaction = self.filteredNetworkTransactions[indexPath.row];
     }
     return transaction;
 }

+ 1 - 1
Classes/Network/FLEXNetworkSettingsTableViewController.m

@@ -92,7 +92,7 @@
 
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
 {
-    return [self.cells objectAtIndex:indexPath.row];
+    return self.cells[indexPath.row];
 }
 
 #pragma mark - UIActionSheetDelegate

+ 4 - 4
Classes/Network/FLEXNetworkTransactionDetailTableViewController.m

@@ -151,13 +151,13 @@ typedef UIViewController *(^FLEXNetworkDetailRowSelectionFuture)(void);
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {
-    FLEXNetworkDetailSection *sectionModel = [self.sections objectAtIndex:section];
+    FLEXNetworkDetailSection *sectionModel = self.sections[section];
     return [sectionModel.rows count];
 }
 
 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
 {
-    FLEXNetworkDetailSection *sectionModel = [self.sections objectAtIndex:section];
+    FLEXNetworkDetailSection *sectionModel = self.sections[section];
     return sectionModel.title;
 }
 
@@ -200,8 +200,8 @@ typedef UIViewController *(^FLEXNetworkDetailRowSelectionFuture)(void);
 
 - (FLEXNetworkDetailRow *)rowModelAtIndexPath:(NSIndexPath *)indexPath
 {
-    FLEXNetworkDetailSection *sectionModel = [self.sections objectAtIndex:indexPath.section];
-    return [sectionModel.rows objectAtIndex:indexPath.row];
+    FLEXNetworkDetailSection *sectionModel = self.sections[indexPath.section];
+    return sectionModel.rows[indexPath.row];
 }
 
 #pragma mark - Cell Copying

+ 1 - 1
Classes/ObjectExplorers/FLEXArrayExplorerViewController.m

@@ -72,7 +72,7 @@
 - (id)detailObjectForRowCookie:(id)rowCookie
 {
     NSUInteger index = [rowCookie unsignedIntegerValue];
-    return [self.array objectAtIndex:index];
+    return self.array[index];
 }
 
 @end

+ 15 - 15
Classes/ObjectExplorers/FLEXObjectExplorerViewController.m

@@ -273,7 +273,7 @@ static const NSInteger kFLEXObjectExplorerScopeIncludeInheritanceIndex = 1;
 
 - (NSString *)titleForPropertyAtIndex:(NSInteger)index
 {
-    FLEXPropertyBox *propertyBox = [self.filteredProperties objectAtIndex:index];
+    FLEXPropertyBox *propertyBox = self.filteredProperties[index];
     return [FLEXRuntimeUtility prettyNameForProperty:propertyBox.property];
 }
 
@@ -281,7 +281,7 @@ static const NSInteger kFLEXObjectExplorerScopeIncludeInheritanceIndex = 1;
 {
     id value = nil;
     if ([self canHaveInstanceState]) {
-        FLEXPropertyBox *propertyBox = [self.filteredProperties objectAtIndex:index];
+        FLEXPropertyBox *propertyBox = self.filteredProperties[index];
         value = [FLEXRuntimeUtility valueForProperty:propertyBox.property onObject:self.object];
     }
     return value;
@@ -352,7 +352,7 @@ static const NSInteger kFLEXObjectExplorerScopeIncludeInheritanceIndex = 1;
 
 - (NSString *)titleForIvarAtIndex:(NSInteger)index
 {
-    FLEXIvarBox *ivarBox = [self.filteredIvars objectAtIndex:index];
+    FLEXIvarBox *ivarBox = self.filteredIvars[index];
     return [FLEXRuntimeUtility prettyNameForIvar:ivarBox.ivar];
 }
 
@@ -360,7 +360,7 @@ static const NSInteger kFLEXObjectExplorerScopeIncludeInheritanceIndex = 1;
 {
     id value = nil;
     if ([self canHaveInstanceState]) {
-        FLEXIvarBox *ivarBox = [self.filteredIvars objectAtIndex:index];
+        FLEXIvarBox *ivarBox = self.filteredIvars[index];
         value = [FLEXRuntimeUtility valueForIvar:ivarBox.ivar onObject:self.object];
     }
     return value;
@@ -451,13 +451,13 @@ static const NSInteger kFLEXObjectExplorerScopeIncludeInheritanceIndex = 1;
 
 - (NSString *)titleForMethodAtIndex:(NSInteger)index
 {
-    FLEXMethodBox *methodBox = [self.filteredMethods objectAtIndex:index];
+    FLEXMethodBox *methodBox = self.filteredMethods[index];
     return [FLEXRuntimeUtility prettyNameForMethod:methodBox.method isClassMethod:NO];
 }
 
 - (NSString *)titleForClassMethodAtIndex:(NSInteger)index
 {
-    FLEXMethodBox *classMethodBox = [self.filteredClassMethods objectAtIndex:index];
+    FLEXMethodBox *classMethodBox = self.filteredClassMethods[index];
     return [FLEXRuntimeUtility prettyNameForMethod:classMethodBox.method isClassMethod:YES];
 }
 
@@ -612,7 +612,7 @@ static const NSInteger kFLEXObjectExplorerScopeIncludeInheritanceIndex = 1;
             break;
             
         case FLEXObjectExplorerSectionSuperclasses:
-            title = NSStringFromClass([self.filteredSuperclasses objectAtIndex:row]);
+            title = NSStringFromClass(self.filteredSuperclasses[row]);
             break;
             
         case FLEXObjectExplorerSectionReferencingInstances:
@@ -669,7 +669,7 @@ static const NSInteger kFLEXObjectExplorerScopeIncludeInheritanceIndex = 1;
             
         case FLEXObjectExplorerSectionProperties: {
             if ([self canHaveInstanceState]) {
-                FLEXPropertyBox *propertyBox = [self.filteredProperties objectAtIndex:row];
+                FLEXPropertyBox *propertyBox = self.filteredProperties[row];
                 objc_property_t property = propertyBox.property;
                 id currentValue = [self valueForPropertyAtIndex:row];
                 BOOL canEdit = [FLEXPropertyEditorViewController canEditProperty:property currentValue:currentValue];
@@ -680,7 +680,7 @@ static const NSInteger kFLEXObjectExplorerScopeIncludeInheritanceIndex = 1;
             
         case FLEXObjectExplorerSectionIvars: {
             if ([self canHaveInstanceState]) {
-                FLEXIvarBox *ivarBox = [self.filteredIvars objectAtIndex:row];
+                FLEXIvarBox *ivarBox = self.filteredIvars[row];
                 Ivar ivar = ivarBox.ivar;
                 id currentValue = [self valueForIvarAtIndex:row];
                 BOOL canEdit = [FLEXIvarEditorViewController canEditIvar:ivar currentValue:currentValue];
@@ -790,7 +790,7 @@ static const NSInteger kFLEXObjectExplorerScopeIncludeInheritanceIndex = 1;
             break;
             
         case FLEXObjectExplorerSectionProperties: {
-            FLEXPropertyBox *propertyBox = [self.filteredProperties objectAtIndex:row];
+            FLEXPropertyBox *propertyBox = self.filteredProperties[row];
             objc_property_t property = propertyBox.property;
             id currentValue = [self valueForPropertyAtIndex:row];
             if ([FLEXPropertyEditorViewController canEditProperty:property currentValue:currentValue]) {
@@ -801,7 +801,7 @@ static const NSInteger kFLEXObjectExplorerScopeIncludeInheritanceIndex = 1;
         } break;
             
         case FLEXObjectExplorerSectionIvars: {
-            FLEXIvarBox *ivarBox = [self.filteredIvars objectAtIndex:row];
+            FLEXIvarBox *ivarBox = self.filteredIvars[row];
             Ivar ivar = ivarBox.ivar;
             id currentValue = [self valueForIvarAtIndex:row];
             if ([FLEXIvarEditorViewController canEditIvar:ivar currentValue:currentValue]) {
@@ -812,19 +812,19 @@ static const NSInteger kFLEXObjectExplorerScopeIncludeInheritanceIndex = 1;
         } break;
             
         case FLEXObjectExplorerSectionMethods: {
-            FLEXMethodBox *methodBox = [self.filteredMethods objectAtIndex:row];
+            FLEXMethodBox *methodBox = self.filteredMethods[row];
             Method method = methodBox.method;
             viewController = [[FLEXMethodCallingViewController alloc] initWithTarget:self.object method:method];
         } break;
             
         case FLEXObjectExplorerSectionClassMethods: {
-            FLEXMethodBox *methodBox = [self.filteredClassMethods objectAtIndex:row];
+            FLEXMethodBox *methodBox = self.filteredClassMethods[row];
             Method method = methodBox.method;
             viewController = [[FLEXMethodCallingViewController alloc] initWithTarget:[self.object class] method:method];
         } break;
             
         case FLEXObjectExplorerSectionSuperclasses: {
-            Class superclass = [self.filteredSuperclasses objectAtIndex:row];
+            Class superclass = self.filteredSuperclasses[row];
             viewController = [FLEXObjectExplorerFactory explorerViewControllerForObject:superclass];
         } break;
             
@@ -972,7 +972,7 @@ static const NSInteger kFLEXObjectExplorerScopeIncludeInheritanceIndex = 1;
     if ([self.filterText length] > 0) {
         filteredIndexSet = [filteredIndexSet indexesPassingTest:^BOOL(NSUInteger index, BOOL *stop) {
             BOOL matches = NO;
-            NSString *rowTitle = [self customSectionTitleForRowCookie:[self.cachedCustomSectionRowCookies objectAtIndex:index]];
+            NSString *rowTitle = [self customSectionTitleForRowCookie:self.cachedCustomSectionRowCookies[index]];
             if ([rowTitle rangeOfString:self.filterText options:NSCaseInsensitiveSearch].location != NSNotFound) {
                 matches = YES;
             }

+ 1 - 1
Classes/Utility/FLEXRuntimeUtility.m

@@ -316,7 +316,7 @@ const unsigned int kFLEXNumberOfImplicitArgs = 2;
     NSUInteger numberOfArguments = [methodSignature numberOfArguments];
     for (NSUInteger argumentIndex = kFLEXNumberOfImplicitArgs; argumentIndex < numberOfArguments; argumentIndex++) {
         NSUInteger argumentsArrayIndex = argumentIndex - kFLEXNumberOfImplicitArgs;
-        id argumentObject = [arguments count] > argumentsArrayIndex ? [arguments objectAtIndex:argumentsArrayIndex] : nil;
+        id argumentObject = [arguments count] > argumentsArrayIndex ? arguments[argumentsArrayIndex] : nil;
         
         // NSNull in the arguments array can be passed as a placeholder to indicate nil. We only need to set the argument if it will be non-nil.
         if (argumentObject && ![argumentObject isKindOfClass:[NSNull class]]) {

+ 3 - 3
Classes/ViewHierarchy/FLEXHierarchyTableViewController.m

@@ -162,7 +162,7 @@ static const NSInteger kFLEXHierarchyScopeFullHierarchyIndex = 1;
         cell = [[FLEXHierarchyTableViewCell alloc] initWithReuseIdentifier:CellIdentifier];
     }
     
-    UIView *view = [self.displayedViews objectAtIndex:indexPath.row];
+    UIView *view = self.displayedViews[indexPath.row];
     NSNumber *depth = [self.depthsForViews objectForKey:[NSValue valueWithNonretainedObject:view]];
     UIColor *viewColor = [FLEXUtility consistentRandomColorForObject:view];
     cell.textLabel.text = [FLEXUtility descriptionForView:view includingFrame:NO];
@@ -182,13 +182,13 @@ static const NSInteger kFLEXHierarchyScopeFullHierarchyIndex = 1;
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
-    self.selectedView = [self.displayedViews objectAtIndex:indexPath.row];
+    self.selectedView = self.displayedViews[indexPath.row];
     [self.delegate hierarchyViewController:self didFinishWithSelectedView:self.selectedView];
 }
 
 - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
 {
-    UIView *drillInView = [self.displayedViews objectAtIndex:indexPath.row];
+    UIView *drillInView = self.displayedViews[indexPath.row];
     FLEXObjectExplorerViewController *viewExplorer = [FLEXObjectExplorerFactory explorerViewControllerForObject:drillInView];
     [self.navigationController pushViewController:viewExplorer animated:YES];
 }