Changeset 11714 for lang/objective-c

Show
Ignore:
Timestamp:
05/17/08 03:49:27 (6 months ago)
Author:
mootoh
Message:

adding UnitTest? case.

Location:
lang/objective-c/HatebuCoreData
Files:
7 added
2 removed
4 modified

Legend:

Unmodified
Added
Removed
  • lang/objective-c/HatebuCoreData/Bookmark.h

    r11706 r11714  
    1111 
    1212@interface Bookmark : NSManagedObject { 
     13  BOOL updated_; 
    1314 
    1415} 
    1516 
    16 - (void) awakeFromFetch; 
     17-(void)update; 
    1718 
    1819@end 
  • lang/objective-c/HatebuCoreData/Bookmark.m

    r11706 r11714  
    99#import "Bookmark.h" 
    1010 
    11  
    1211@implementation Bookmark 
    13  
     12#if 0 
    1413- (void) awakeFromFetch { 
    1514  NSLog(@"Bookmark#awakeFromFetch: %@", self); 
    1615} 
     16#endif // 0 
     17 
     18- (void) willSave { 
     19  NSLog(@"Bookmark#willSave: %@", self); 
     20  [self update]; 
     21} 
     22 
     23-(void) update { 
     24  abort(); 
     25} 
    1726 
    1827@end 
  • lang/objective-c/HatebuCoreData/HatebuCoreData.xcodeproj/project.pbxproj

    r11706 r11714  
    1414                8609DD8F0DDC0DF300E2B4DD /* BookmarkController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8609DD8E0DDC0DF300E2B4DD /* BookmarkController.m */; }; 
    1515                8698C85D0DDD60B800294DC6 /* Bookmark.m in Sources */ = {isa = PBXBuildFile; fileRef = 8698C85C0DDD60B800294DC6 /* Bookmark.m */; }; 
    16                 8698C8630DDD83AE00294DC6 /* NetworkProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 8698C8620DDD83AE00294DC6 /* NetworkProxy.m */; }; 
     16                8698C8850DDDBC9000294DC6 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8698C8840DDDBC9000294DC6 /* SenTestingKit.framework */; }; 
     17                86FD38540DDE09EE0016EAA6 /* FakeBookmark.m in Sources */ = {isa = PBXBuildFile; fileRef = 86FD38530DDE09EE0016EAA6 /* FakeBookmark.m */; }; 
     18                86FD385A0DDE0AB70016EAA6 /* BookmarkTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 86FD38590DDE0AB70016EAA6 /* BookmarkTest.m */; }; 
     19                86FD38600DDE0B4C0016EAA6 /* Bookmark.m in Sources */ = {isa = PBXBuildFile; fileRef = 8698C85C0DDD60B800294DC6 /* Bookmark.m */; }; 
    1720                8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; 
    1821                8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 
     
    3841                8698C85B0DDD60B800294DC6 /* Bookmark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bookmark.h; sourceTree = "<group>"; }; 
    3942                8698C85C0DDD60B800294DC6 /* Bookmark.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bookmark.m; sourceTree = "<group>"; }; 
    40                 8698C8610DDD83AE00294DC6 /* NetworkProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkProxy.h; sourceTree = "<group>"; }; 
    41                 8698C8620DDD83AE00294DC6 /* NetworkProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NetworkProxy.m; sourceTree = "<group>"; }; 
     43                8698C8700DDDBB8700294DC6 /* UnitTest.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTest.octest; sourceTree = BUILT_PRODUCTS_DIR; }; 
     44                8698C8710DDDBB8700294DC6 /* UnitTest-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UnitTest-Info.plist"; sourceTree = "<group>"; }; 
     45                8698C8840DDDBC9000294DC6 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; 
     46                86FD383A0DDE073A0016EAA6 /* HatenaBookmark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HatenaBookmark.h; sourceTree = "<group>"; }; 
     47                86FD383B0DDE073A0016EAA6 /* HatenaBookmark.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HatenaBookmark.m; sourceTree = "<group>"; }; 
     48                86FD38520DDE09EE0016EAA6 /* FakeBookmark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FakeBookmark.h; sourceTree = "<group>"; }; 
     49                86FD38530DDE09EE0016EAA6 /* FakeBookmark.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FakeBookmark.m; sourceTree = "<group>"; }; 
     50                86FD38580DDE0AB70016EAA6 /* BookmarkTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BookmarkTest.h; sourceTree = "<group>"; }; 
     51                86FD38590DDE0AB70016EAA6 /* BookmarkTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BookmarkTest.m; sourceTree = "<group>"; }; 
    4252                8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 
    4353                8D1107320486CEB800E47090 /* HatebuCoreData.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HatebuCoreData.app; sourceTree = BUILT_PRODUCTS_DIR; }; 
     
    4555 
    4656/* Begin PBXFrameworksBuildPhase section */ 
     57                8698C86D0DDDBB8700294DC6 /* Frameworks */ = { 
     58                        isa = PBXFrameworksBuildPhase; 
     59                        buildActionMask = 2147483647; 
     60                        files = ( 
     61                                8698C8850DDDBC9000294DC6 /* SenTestingKit.framework in Frameworks */, 
     62                        ); 
     63                        runOnlyForDeploymentPostprocessing = 0; 
     64                }; 
    4765                8D11072E0486CEB800E47090 /* Frameworks */ = { 
    4866                        isa = PBXFrameworksBuildPhase; 
     
    6785                                8698C85B0DDD60B800294DC6 /* Bookmark.h */, 
    6886                                8698C85C0DDD60B800294DC6 /* Bookmark.m */, 
    69                                 8698C8610DDD83AE00294DC6 /* NetworkProxy.h */, 
    70                                 8698C8620DDD83AE00294DC6 /* NetworkProxy.m */, 
     87                                86FD383A0DDE073A0016EAA6 /* HatenaBookmark.h */, 
     88                                86FD383B0DDE073A0016EAA6 /* HatenaBookmark.m */, 
     89                                86FD38520DDE09EE0016EAA6 /* FakeBookmark.h */, 
     90                                86FD38530DDE09EE0016EAA6 /* FakeBookmark.m */, 
    7191                        ); 
    7292                        name = Classes; 
     
    7696                        isa = PBXGroup; 
    7797                        children = ( 
     98                                8698C8840DDDBC9000294DC6 /* SenTestingKit.framework */, 
    7899                                1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, 
    79100                        ); 
     
    95116                        children = ( 
    96117                                8D1107320486CEB800E47090 /* HatebuCoreData.app */, 
     118                                8698C8700DDDBB8700294DC6 /* UnitTest.octest */, 
    97119                        ); 
    98120                        name = Products; 
     
    102124                        isa = PBXGroup; 
    103125                        children = ( 
     126                                8698C8750DDDBBE100294DC6 /* Test Cases */, 
    104127                                7756732906782D8800D1FEB8 /* Models */, 
    105128                                080E96DDFE201D6D7F000001 /* Classes */, 
     
    109132                                19C28FACFE9D520D11CA2CBB /* Products */, 
    110133                                8609D26E0DDC212C00589FA4 /* MainMenu.nib */, 
     134                                8698C8710DDDBB8700294DC6 /* UnitTest-Info.plist */, 
    111135                        ); 
    112136                        name = HatebuCoreData; 
     
    148172                        sourceTree = "<group>"; 
    149173                }; 
     174                8698C8750DDDBBE100294DC6 /* Test Cases */ = { 
     175                        isa = PBXGroup; 
     176                        children = ( 
     177                                86FD38580DDE0AB70016EAA6 /* BookmarkTest.h */, 
     178                                86FD38590DDE0AB70016EAA6 /* BookmarkTest.m */, 
     179                        ); 
     180                        name = "Test Cases"; 
     181                        sourceTree = "<group>"; 
     182                }; 
    150183/* End PBXGroup section */ 
    151184 
    152185/* Begin PBXNativeTarget section */ 
     186                8698C86F0DDDBB8700294DC6 /* UnitTest */ = { 
     187                        isa = PBXNativeTarget; 
     188                        buildConfigurationList = 8698C8740DDDBB8800294DC6 /* Build configuration list for PBXNativeTarget "UnitTest" */; 
     189                        buildPhases = ( 
     190                                8698C86B0DDDBB8700294DC6 /* Resources */, 
     191                                8698C86C0DDDBB8700294DC6 /* Sources */, 
     192                                8698C86D0DDDBB8700294DC6 /* Frameworks */, 
     193                                8698C86E0DDDBB8700294DC6 /* ShellScript */, 
     194                        ); 
     195                        buildRules = ( 
     196                        ); 
     197                        dependencies = ( 
     198                        ); 
     199                        name = UnitTest; 
     200                        productName = UnitTest; 
     201                        productReference = 8698C8700DDDBB8700294DC6 /* UnitTest.octest */; 
     202                        productType = "com.apple.product-type.bundle"; 
     203                }; 
    153204                8D1107260486CEB800E47090 /* HatebuCoreData */ = { 
    154205                        isa = PBXNativeTarget; 
     
    182233                        targets = ( 
    183234                                8D1107260486CEB800E47090 /* HatebuCoreData */, 
     235                                8698C86F0DDDBB8700294DC6 /* UnitTest */, 
    184236                        ); 
    185237                }; 
     
    187239 
    188240/* Begin PBXResourcesBuildPhase section */ 
     241                8698C86B0DDDBB8700294DC6 /* Resources */ = { 
     242                        isa = PBXResourcesBuildPhase; 
     243                        buildActionMask = 2147483647; 
     244                        files = ( 
     245                        ); 
     246                        runOnlyForDeploymentPostprocessing = 0; 
     247                }; 
    189248                8D1107290486CEB800E47090 /* Resources */ = { 
    190249                        isa = PBXResourcesBuildPhase; 
     
    198257/* End PBXResourcesBuildPhase section */ 
    199258 
     259/* Begin PBXShellScriptBuildPhase section */ 
     260                8698C86E0DDDBB8700294DC6 /* ShellScript */ = { 
     261                        isa = PBXShellScriptBuildPhase; 
     262                        buildActionMask = 2147483647; 
     263                        files = ( 
     264                        ); 
     265                        inputPaths = ( 
     266                        ); 
     267                        outputPaths = ( 
     268                        ); 
     269                        runOnlyForDeploymentPostprocessing = 0; 
     270                        shellPath = /bin/sh; 
     271                        shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; 
     272                }; 
     273/* End PBXShellScriptBuildPhase section */ 
     274 
    200275/* Begin PBXSourcesBuildPhase section */ 
     276                8698C86C0DDDBB8700294DC6 /* Sources */ = { 
     277                        isa = PBXSourcesBuildPhase; 
     278                        buildActionMask = 2147483647; 
     279                        files = ( 
     280                                86FD38540DDE09EE0016EAA6 /* FakeBookmark.m in Sources */, 
     281                                86FD385A0DDE0AB70016EAA6 /* BookmarkTest.m in Sources */, 
     282                                86FD38600DDE0B4C0016EAA6 /* Bookmark.m in Sources */, 
     283                        ); 
     284                        runOnlyForDeploymentPostprocessing = 0; 
     285                }; 
    201286                8D11072C0486CEB800E47090 /* Sources */ = { 
    202287                        isa = PBXSourcesBuildPhase; 
     
    209294                                8609DD8F0DDC0DF300E2B4DD /* BookmarkController.m in Sources */, 
    210295                                8698C85D0DDD60B800294DC6 /* Bookmark.m in Sources */, 
    211                                 8698C8630DDD83AE00294DC6 /* NetworkProxy.m in Sources */, 
    212296                        ); 
    213297                        runOnlyForDeploymentPostprocessing = 0; 
     
    291375                        name = Release; 
    292376                }; 
     377                8698C8720DDDBB8700294DC6 /* Debug */ = { 
     378                        isa = XCBuildConfiguration; 
     379                        buildSettings = { 
     380                                ALWAYS_SEARCH_USER_PATHS = NO; 
     381                                ARCHS = "$(NATIVE_ARCH)"; 
     382                                COPY_PHASE_STRIP = NO; 
     383                                FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; 
     384                                GCC_DYNAMIC_NO_PIC = NO; 
     385                                GCC_ENABLE_FIX_AND_CONTINUE = NO; 
     386                                GCC_ENABLE_OBJC_EXCEPTIONS = YES; 
     387                                GCC_MODEL_TUNING = G5; 
     388                                GCC_OPTIMIZATION_LEVEL = 0; 
     389                                GCC_PRECOMPILE_PREFIX_HEADER = YES; 
     390                                GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h"; 
     391                                INFOPLIST_FILE = "UnitTest-Info.plist"; 
     392                                INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; 
     393                                OTHER_LDFLAGS = ( 
     394                                        "-framework", 
     395                                        Cocoa, 
     396                                        "-framework", 
     397                                        SenTestingKit, 
     398                                ); 
     399                                PREBINDING = NO; 
     400                                PRODUCT_NAME = UnitTest; 
     401                                WRAPPER_EXTENSION = octest; 
     402                        }; 
     403                        name = Debug; 
     404                }; 
     405                8698C8730DDDBB8700294DC6 /* Release */ = { 
     406                        isa = XCBuildConfiguration; 
     407                        buildSettings = { 
     408                                ALWAYS_SEARCH_USER_PATHS = NO; 
     409                                ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 
     410                                COPY_PHASE_STRIP = YES; 
     411                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 
     412                                FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; 
     413                                GCC_ENABLE_FIX_AND_CONTINUE = NO; 
     414                                GCC_ENABLE_OBJC_EXCEPTIONS = YES; 
     415                                GCC_MODEL_TUNING = G5; 
     416                                GCC_PRECOMPILE_PREFIX_HEADER = YES; 
     417                                GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h"; 
     418                                INFOPLIST_FILE = "UnitTest-Info.plist"; 
     419                                INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; 
     420                                OTHER_LDFLAGS = ( 
     421                                        "-framework", 
     422                                        Cocoa, 
     423                                        "-framework", 
     424                                        SenTestingKit, 
     425                                ); 
     426                                PREBINDING = NO; 
     427                                PRODUCT_NAME = UnitTest; 
     428                                WRAPPER_EXTENSION = octest; 
     429                                ZERO_LINK = NO; 
     430                        }; 
     431                        name = Release; 
     432                }; 
    293433/* End XCBuildConfiguration section */ 
    294434 
     
    312452                        defaultConfigurationName = Release; 
    313453                }; 
     454                8698C8740DDDBB8800294DC6 /* Build configuration list for PBXNativeTarget "UnitTest" */ = { 
     455                        isa = XCConfigurationList; 
     456                        buildConfigurations = ( 
     457                                8698C8720DDDBB8700294DC6 /* Debug */, 
     458                                8698C8730DDDBB8700294DC6 /* Release */, 
     459                        ); 
     460                        defaultConfigurationIsVisible = 0; 
     461                        defaultConfigurationName = Release; 
     462                }; 
    314463/* End XCConfigurationList section */ 
    315464        }; 
  • lang/objective-c/HatebuCoreData/HatebuCoreData_AppDelegate.m

    r11706 r11714  
    1919 */ 
    2020- (NSString *)applicationSupportFolder { 
    21          
     21   
    2222    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); 
    2323    NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : NSTemporaryDirectory(); 
     
    3030 */ 
    3131- (NSManagedObjectModel *)managedObjectModel { 
    32          
     32   
    3333    if (managedObjectModel != nil) { 
    3434        return managedObjectModel; 
    3535    } 
    36          
     36   
    3737    managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];     
    3838    return managedObjectModel; 
     
    4747 */ 
    4848- (NSPersistentStoreCoordinator *) persistentStoreCoordinator { 
    49          
     49   
    5050    if (persistentStoreCoordinator != nil) { 
    5151        return persistentStoreCoordinator; 
    5252    } 
    53          
     53   
    5454    NSFileManager *fileManager; 
    5555    NSString *applicationSupportFolder = nil; 
     
    6868        [[NSApplication sharedApplication] presentError:error]; 
    6969    }     
    70          
     70   
    7171    return persistentStoreCoordinator; 
    7272} 
     
    7777 */ 
    7878- (NSManagedObjectContext *) managedObjectContext { 
    79          
     79   
    8080    if (managedObjectContext != nil) { 
    8181        return managedObjectContext; 
    8282    } 
    83          
     83   
    8484    NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; 
    8585    if (coordinator != nil) { 
     
    105105 */ 
    106106- (IBAction) saveAction:(id)sender { 
    107          
     107   
    108108    NSError *error = nil; 
    109109    if (![[self managedObjectContext] save:&error]) { 
     
    119119 */ 
    120120- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { 
    121          
     121   
    122122    NSError *error; 
    123123    int reply = NSTerminateNow; 
     
    126126        if ([managedObjectContext commitEditing]) { 
    127127            if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) { 
    128                                  
     128         
    129129                // This error handling simply presents error information in a panel with an  
    130130                // "Ok" button, which does not include any attempt at error recovery (meaning,  
     
    132132                // present the information to the user and then follow up with a panel asking  
    133133                // if the user wishes to "Quit Anyway", without saving the changes. 
    134                                  
     134         
    135135                // Typically, this process should be altered to include application-specific  
    136136                // recovery steps.   
    137                                  
     137         
    138138                BOOL errorResult = [[NSApplication sharedApplication] presentError:error]; 
    139                                  
     139         
    140140                if (errorResult == YES) { 
    141141                    reply = NSTerminateCancel; 
    142142                }  
    143                                  
     143         
    144144                else { 
    145                                          
     145           
    146146                    int alertReturn = NSRunAlertPanel(nil, @"Could not save changes while quitting. Quit anyway?" , @"Quit anyway", @"Cancel", nil); 
    147147                    if (alertReturn == NSAlertAlternateReturn) { 
    148                         reply = NSTerminateCancel;       
     148                        reply = NSTerminateCancel;   
    149149                    } 
    150150                } 
    151151            } 
    152152        }  
    153          
    154153        else { 
    155154            reply = NSTerminateCancel; 
    156155        } 
    157156    } 
    158      
     157 
    159158    return reply; 
    160159} 
     
    172171 
    173172- (void)addEntry:(NSXMLElement *)entry { 
    174         NSManagedObject *bmk = [NSEntityDescription 
     173  NSManagedObject *bmk = [NSEntityDescription 
    175174    insertNewObjectForEntityForName:@"Bookmark" 
    176175             inManagedObjectContext:[self managedObjectContext]]; 
    177          
    178         NSString *title = [[[entry elementsForName: @"title"] objectAtIndex:0] stringValue]; 
    179         NSLog(@"title = %@", title); 
    180         [bmk setValue:title forKey:@"title"]; 
    181          
    182         NSArray *urls = [entry elementsForName:@"link"]; 
    183         for (NSXMLElement *url in urls) { 
    184                 if ([[[url attributeForName:@"rel"] stringValue] compare:@"related"]) { 
    185                         NSString *siteUrl = [[url attributeForName:@"href"] stringValue]; 
    186                         NSLog(@"siteUrl = %@", siteUrl); 
    187                         [bmk setValue:siteUrl forKey:@"siteUrl"]; 
    188                 } else { 
    189                         NSString *bookmarkUrl = [[url attributeForName:@"href"] stringValue]; 
    190                         NSLog(@"bookmarkUrl = %@", bookmarkUrl); 
    191                         [bmk setValue:bookmarkUrl forKey:@"bookmarkUrl"]; 
    192                 } 
    193         } 
    194          
    195         NSString *issued = [[[entry elementsForName: @"issued"] objectAtIndex:0] stringValue]; 
    196         issued = [issued stringByReplacingOccurrencesOfString:@"T" withString:@" "]; 
    197         issued = [issued stringByReplacingOccurrencesOfString:@"+" withString:@" +"]; 
    198         // issued = [issued stringByReplacingOccurrencesOfString:@"-" withString:@" -"]; // XXX BUG: won't work outside of Japan (Timezone +09:00) 
    199         NSDate *date = [NSDate dateWithString:issued]; 
    200         NSLog(@"issued: %@", issued); 
    201         [bmk setValue:date forKey:@"issued"]; 
    202         NSString *body = [[[entry elementsForName: @"summary"] objectAtIndex:0] stringValue]; 
    203         NSLog(@"body: %@", body); 
    204         [bmk setValue:body forKey:@"body"]; 
    205          
    206         NSMutableSet *tag_set = [[NSMutableSet alloc] init]; 
    207         NSLog(@"tag_set: %@", tag_set); 
    208         NSArray *tags = [entry elementsForName:@"dc:subject"]; 
    209         NSLog(@"tags: %@", tags); 
    210          
    211         for (NSXMLElement *t in tags) { 
    212                 NSString *name = [t stringValue]; 
    213                  
    214                 NSPredicate *pred = [NSPredicate predicateWithFormat:@"name == %@", name]; 
    215                 NSEntityDescription *entity = [NSEntityDescription entityForName:@"Tag" inManagedObjectContext:[self managedObjectContext]]; 
    216                  
    217                 NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; 
    218                 [request setEntity:entity]; 
    219                 [request setPredicate:pred]; 
    220                  
    221                 NSManagedObject *tag; 
    222                  
    223                 if (0 < [[self managedObjectContext] countForFetchRequest:request error:nil]) { // tag already exists 
    224                         NSArray *arr = [[self managedObjectContext] executeFetchRequest:request error:nil]; 
    225                         tag = [arr objectAtIndex:0]; 
    226                 } else { 
    227                         tag = [NSEntityDescription insertNewObjectForEntityForName:@"Tag" inManagedObjectContext:[self managedObjectContext]]; 
    228                         [tag setValue:name forKey:@"name"]; 
    229                 } 
    230                 [tag_set addObject:tag]; 
    231                 NSLog(@"added: %@", tag); 
    232         } 
    233         [bmk setValue:tag_set forKey:@"tags"]; 
     176 
     177  NSString *title = [[[entry elementsForName: @"title"] objectAtIndex:0] stringValue]; 
     178  NSLog(@"title = %@", title); 
     179  [bmk setValue:title forKey:@"title"]; 
     180 
     181  NSArray *urls = [entry elementsForName:@"link"]; 
     182  for (NSXMLElement *url in urls) { 
     183    if ([[[url attributeForName:@"rel"] stringValue] compare:@"related"]) { 
     184      NSString *siteUrl = [[url attributeForName:@"href"] stringValue]; 
     185      NSLog(@"siteUrl = %@", siteUrl); 
     186      [bmk setValue:siteUrl forKey:@"siteUrl"]; 
     187    } else { 
     188      NSString *bookmarkUrl = [[url attributeForName:@"href"] stringValue]; 
     189      NSLog(@"bookmarkUrl = %@", bookmarkUrl); 
     190      [bmk setValue:bookmarkUrl forKey:@"bookmarkUrl"]; 
     191    } 
     192  } 
     193 
     194  NSString *issued = [[[entry elementsForName: @"issued"] objectAtIndex:0] stringValue]; 
     195  issued = [issued stringByReplacingOccurrencesOfString:@"T" withString:@" "]; 
     196  issued = [issued stringByReplacingOccurrencesOfString:@"+" withString:@" +"]; 
     197  // issued = [issued stringByReplacingOccurrencesOfString:@"-" withString:@" -"]; // XXX BUG: won't work outside of Japan (Timezone +09:00) 
     198  NSDate *date = [NSDate dateWithString:issued]; 
     199  NSLog(@"issued: %@", issued); 
     200  [bmk setValue:date forKey:@"issued"]; 
     201  NSString *body = [[[entry elementsForName: @"summary"] objectAtIndex:0] stringValue]; 
     202  NSLog(@"body: %@", body); 
     203  [bmk setValue:body forKey:@"body"]; 
     204   
     205  NSMutableSet *tag_set = [[NSMutableSet alloc] init]; 
     206  NSLog(@"tag_set: %@", tag_set); 
     207  NSArray *tags = [entry elementsForName:@"dc:subject"]; 
     208  NSLog(@"tags: %@", tags); 
     209 
     210  for (NSXMLElement *t in tags) { 
     211    NSString *name = [t stringValue]; 
     212 
     213    NSPredicate *pred = [NSPredicate predicateWithFormat:@"name == %@", name]; 
     214    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Tag" inManagedObjectContext:[self managedObjectContext]]; 
     215 
     216    NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; 
     217    [request setEntity:entity]; 
     218    [request setPredicate:pred]; 
     219 
     220    NSManagedObject *tag; 
     221 
     222    if (0 < [[self managedObjectContext] countForFetchRequest:request error:nil]) { // tag already exists 
     223      NSArray *arr = [[self managedObjectContext] executeFetchRequest:request error:nil]; 
     224