Revision: 6717
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6717&view=rev
Author:   hofman
Date:     2010-08-19 17:09:41 +0000 (Thu, 19 Aug 2010)

Log Message:
-----------
return recent document info dictionary rather than its index

Modified Paths:
--------------
    trunk/SKBookmarkController.m

Modified: trunk/SKBookmarkController.m
===================================================================
--- trunk/SKBookmarkController.m        2010-08-19 10:09:46 UTC (rev 6716)
+++ trunk/SKBookmarkController.m        2010-08-19 17:09:41 UTC (rev 6717)
@@ -274,30 +274,26 @@
 
 #pragma mark Recent Documents
 
-- (NSUInteger)indexOfRecentDocumentAtPath:(NSString *)path {
-    NSUInteger idx = NSNotFound, i, iMax = [recentDocuments count];
-    for (i = 0; i < iMax; i++) {
-        NSMutableDictionary *info = [recentDocuments objectAtIndex:i];
+- (NSDictionary *)recentDocumentInfoAtPath:(NSString *)path {
+    for (NSMutableDictionary *info in recentDocuments) {
         BDAlias *alias = [info valueForKey:ALIAS_KEY];
         if (alias == nil) {
             alias = [BDAlias aliasWithData:[info valueForKey:ALIASDATA_KEY]];
             [info setValue:alias forKey:ALIAS_KEY];
         }
-        if ([[alias fullPathNoUI] isEqualToString:path]) {
-            idx = i;
-            break;
-        }
+        if ([[alias fullPathNoUI] isEqualToString:path])
+            return info;
     }
-    return idx;
+    return nil;
 }
 
 - (void)addRecentDocumentForPath:(NSString *)path 
pageIndex:(NSUInteger)pageIndex snapshots:(NSArray *)setups {
     if (path == nil)
         return;
     
-    NSUInteger idx = [self indexOfRecentDocumentAtPath:path];
-    if (idx != NSNotFound)
-        [recentDocuments removeObjectAtIndex:idx];
+    NSDictionary *info = [self recentDocumentInfoAtPath:path];
+    if (info)
+        [recentDocuments removeObjectIdenticalTo:info];
     
     BDAlias *alias = [BDAlias aliasWithPath:path];
     if (alias) {
@@ -311,15 +307,14 @@
 - (NSUInteger)pageIndexForRecentDocumentAtPath:(NSString *)path {
     if (path == nil)
         return NSNotFound;
-    NSUInteger idx = [self indexOfRecentDocumentAtPath:path];
-    return idx == NSNotFound ? NSNotFound : [[[recentDocuments 
objectAtIndex:idx] objectForKey:PAGEINDEX_KEY] unsignedIntegerValue];
+    NSDictionary *info = [self recentDocumentInfoAtPath:path];
+    return info == nil ? NSNotFound : [[info objectForKey:PAGEINDEX_KEY] 
unsignedIntegerValue];
 }
 
 - (NSArray *)snapshotsForRecentDocumentAtPath:(NSString *)path {
     if (path == nil)
         return nil;
-    NSUInteger idx = [self indexOfRecentDocumentAtPath:path];
-    NSArray *setups = idx == NSNotFound ? nil : [[recentDocuments 
objectAtIndex:idx] objectForKey:SNAPSHOTS_KEY];
+    NSArray *setups = [[self recentDocumentInfoAtPath:path] 
objectForKey:SNAPSHOTS_KEY];
     return [setups count] ? setups : nil;
 }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to