FROM : Charles Ross
DATE : Thu Mar 06 21:35:03 2008
I'm writing an application to teach myself Cocoa. I had originally
written the application using Core Data, but am attempting to rewrite
it without Core Data in order to better learn the Cocoa basics. One of
the features of the new program is that it will import the data from
the existing application.
If I enter the following command in the terminal, it returns about
20,000 records to the screen in about one second:
sqlite3 Videos.sql 'select * from ZVIDEOS'
The file has a fairly large number of records, almost 20,000. However,
the following code, when run from a simple Foundation Tool I built to
figure out what's going on, never gets to the second NSLog statement,
even after running for more than ten minutes. Is this process really
taking that long or am I missing something?
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *file = @"/Users/chuck/Documents/Videos.sql";
NSString *sql = @"select * from ZVIDEOS";
NSTask *t = [NSTask new];
NSPipe *p = [NSPipe new];
NSFileHandle *fh = [p fileHandleForReading];
[t setLaunchPath:@"/usr/bin/sqlite3"];
[t setArguments:[NSArray arrayWithObjects:file, sql, nil]];
[t setStandardOutput:p];
[t launch];
NSLog(@"t launched");
[t waitUntilExit];
NSLog(@"done waiting"); // <-- never reached
NSData *d = [fh availableData];
NSString *output = [NSString stringWithCString:[d bytes]
encoding:NSASCIIStringEncoding];
NSLog(@"%@", output);
[pool drain];
return 0;
}
Thanks,
Chuck Ross
Developer & Writer
(951) 699-0798
mailto:<email_removed>
AIM:mer0dyn
DATE : Thu Mar 06 21:35:03 2008
I'm writing an application to teach myself Cocoa. I had originally
written the application using Core Data, but am attempting to rewrite
it without Core Data in order to better learn the Cocoa basics. One of
the features of the new program is that it will import the data from
the existing application.
If I enter the following command in the terminal, it returns about
20,000 records to the screen in about one second:
sqlite3 Videos.sql 'select * from ZVIDEOS'
The file has a fairly large number of records, almost 20,000. However,
the following code, when run from a simple Foundation Tool I built to
figure out what's going on, never gets to the second NSLog statement,
even after running for more than ten minutes. Is this process really
taking that long or am I missing something?
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *file = @"/Users/chuck/Documents/Videos.sql";
NSString *sql = @"select * from ZVIDEOS";
NSTask *t = [NSTask new];
NSPipe *p = [NSPipe new];
NSFileHandle *fh = [p fileHandleForReading];
[t setLaunchPath:@"/usr/bin/sqlite3"];
[t setArguments:[NSArray arrayWithObjects:file, sql, nil]];
[t setStandardOutput:p];
[t launch];
NSLog(@"t launched");
[t waitUntilExit];
NSLog(@"done waiting"); // <-- never reached
NSData *d = [fh availableData];
NSString *output = [NSString stringWithCString:[d bytes]
encoding:NSASCIIStringEncoding];
NSLog(@"%@", output);
[pool drain];
return 0;
}
Thanks,
Chuck Ross
Developer & Writer
(951) 699-0798
mailto:<email_removed>
AIM:mer0dyn
| Related mails | Author | Date |
|---|---|---|
| Charles Ross | Mar 6, 21:35 | |
| Jens Alfke | Mar 6, 22:06 | |
| Gerd Knops | Mar 10, 22:39 |






Cocoa mail archive

