Blurry UILabel text as programmatic subview of UITableViewCell's contentView
I am adding a UILabel instance as a subview of my custom UITableViewCell instance's contentView property. When I select the cell, the row is highlighted blue, except for the background of the label. The label text is sharp, but the background is white for the bounds of the contentView. When I set the label and contentView backgroundColor property to "[UIColor clearColor]", the UILabel text becomes blurry. How do I set the label and/or contentView background color to be clear, to allow the row highlight color to come through, while still keeping the label text sharp? One suggestion I read elsewhere was to round() the label's frame struct values, but this did not have any effect. Thanks for any advice.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSFetchedResultController bug?
I am reworking Apple's CoreDataBooks sample iPhone application to add five relationship-less instances of an NSManagedObject class ("Book"). When I add these to a secondary managed object context (MOC) and then merge these changes with the primary MOC, the application crashes with the following error: 2009-10-13 02:59:12.787 MyApp[43049:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (7) beyond bounds (7)' If I reopen the application, those five instances are in the data store and are displayed properly in the table view. As they are being added to the Core Data store, it looks like there is something wrong with the table view update process. If I wipe the application and recompile, I get the same symptom. If I first comment out the following line: [_tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade]; in the NSFetchedResultController delegate method: -controller:didChangeObject:atIndexPath:forChangeType:newIndexPath: then the application does not crash on the first insert. But it crashes on a subsequent insert attempts with the following error: 2009-10-13 03:10:19.072 MyApp[43129:207] *** Assertion failure in - [UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/ UIKit-984.38/UITableView.m:774 2009-10-13 03:10:19.073 MyApp[43129:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted).' In this subsequent attempt, I am not adding any Book MOs to the secondary MOC, but the table view is still being refreshed. I suspect this is because -insertRowsAtIndexPaths:withRowAnimation: was commented out, but strangely the table view has the two rows in the first section. Is there a bug with the -insertRowsAtIndexPaths:withRowAnimation: call on the first insert attempt? Is there a way to work around this? Is there a relatively bug-free demonstration or explanation of how to use the NSFetchedResultController class to manage iPhone table view updates properly? Thanks, Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Illegal attempt to establish a relationship 'xyz' between objects in different contexts
I am using the CoreDataBooks sample application as a basis for pulling data into a secondary managed object context in the background, and then merging that data into the primary managed object context. The data I am pulling in is a Book entity with a to-one relationship with an Owner entity (called "owner"). The Owner entity has a to-many relationship with the Book (called "books"). My data is an XML document of the form: alexpreynolds 123456 Book One Book Two ... Book N Book One through Book N are associated with one Owner ("alexpreynolds, 123456"). I am parsing this into an Owner instance and an NSMutableSet made up of Book instances. When I attempt to save the first time, it saves fine and the merged data shows up in the table view. On the second save, however, when the XML content contains a new book, it doesn't work. Here's what happens: I then attempt to load in an XML document that contains a new Book not already in the primary managed object context. The new Book is using the same Owner as that which is associated with the other Books. I have routines that pick out this unique Owner managed object (which I already have in my primary managed object context) and the unique Book that is *not* found in the primary MOC. From this, I create a new Book object in the secondary MOC, and I set its "owner" relationship to point to the unique Owner I found in the primary MOC. When I save, I get the following error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Illegal attempt to establish a relationship 'owner' between objects in different contexts (source = (entity: Book; id: 0x7802ae0 > ; data: { creationDate = 2009-10-12 06:01:53 -0700; name = nil; nameInitial = nil; operations = ( ); owner = nil; type = 0; }) , destination = (entity: Owner; id: 0x3a56f80 > ; data: { books = ""; displayName = alexpreynolds; ownerID = 123456; }))' How do I create the new Book entity in the secondary MOC, so that I can still associate it with a pre-existing Owner in the primary MOC? Thanks for any advice. Regards, Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Does Core Data have reserved Entity names?
On Sep 30, 2009, at 4:04 AM, I. Savant wrote: Whatever the answer, the simple solution is to change your entity's name. Unfortunately, that simple solution means parting ways with the naming scheme of the source I'm pulling data from and changing the naming scheme for all my other entities/classes, too, which I was hoping to avoid. But thanks to all for the confirmation. -Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Does Core Data have reserved Entity names?
After I added an Entity called "Object", I get the following message when executing my application on the iPhone: objc[4219]: Class Object is implemented in both /usr/lib/ libobjc.A.dylib and /var/mobile/Applications/BFDFC14C-DB60-44BB-8118- D2AAB39E2EE6/MyApp.app/MyApp. One of the two will be used. Which one is undefined. Is "Object" a reserved name for a Core Data Entity on an iPhone? I don't see this message when I execute my application on the Simulator. Thanks, Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
What is the best way to call parent view controller methods from within child view controller?
I have a view hierarchy managed with UINavigationController, of the form A -> B, where A and B are UIViewController subclasses. When I am in the B view, I have a backBarButtonItem in the navigation bar that will pop the application back to the A view, when selected. The title of the backBarButtonItem was initially set in A, just before I pushed the B view onto the navigation stack. Assuming I am in B and I would like to change the title of the backBarButtonItem, what is the best way to accomplish this? Currently, I have a method in A that sets the title property value: - (void) setBackBarButtonItemTitle:(NSString *)newTitle { self.navigationItem.backBarButtonItem.title = newTitle; } When in B, I call -viewControllers to get the array of view controllers, referencing the second to last element to call A's - setBackBarButtonItemTitle: NSArray *viewControllerArray = [self.navigationController viewControllers]; int parentViewControllerIndex = [viewControllerArray count] - 2; [[viewControllerArray objectAtIndex:parentViewControllerIndex] setBackBarButtonItemTitle:@"New Title"]; This approach is clunky but it seems to work correctly. However, I don't know why the following does not work, when called within B: [(A *)(self.navigationController.parentViewController) setBackBarButtonItemTitle:@"New Title"]; In fact, calling any parent view methods using the parentViewController property does not work. Why does this second approach (using the parentViewController property) fail to work? Am I not using this property correctly? Thanks, Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data fetch with to-many relationship
I think I found a solution: NSArray *testFetchResults = [managedObjectContext fetchObjectsForEntityName:@"Owner" withPredicate:[NSString stringWithFormat:@"ANY books.name beginswith 'myPrefix'"]]; NSSet *filteredSet = [(NSSet *)[(Owner *)[testFetchResults objectAtIndex:0] buckets] filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"name beginswith 'myPrefix'"] ); NSLog(@"%@", [filteredSet description]); -- {( Book < name: myPrefix-v1 creationDate: 2008-11-10 00:02:35 -0800 Owner < 123456 | username > >, Book < name: myPrefix-v2 creationDate: 2008-11-09 23:58:36 -0800 Owner < 123456 | username > > )} -- -Alex On Sep 8, 2009, at 11:04 PM, Alex Reynolds wrote: Hi Melissa, Thanks for the name change suggestion. When I log the test fetch results: NSArray *testFetchResults = [managedObjectContext fetchObjectsForEntityName:@"Owner" withPredicate:[NSString stringWithFormat:@"ANY books.name like 'myPrefix*'"]]; NSLog([[(Owner *)[testFetchResults objectAtIndex:0] books] valueForKey:@"name"]); I get the following sample output: -- {( "foo", "bar", "myPrefix-v1", "myPrefix-v2" )} -- These were the four test Book objects I originally associated with one Owner, and then saved to the managed object context. I'm unclear why the predicate statement: @"ANY books.name like 'myPrefix*'" would return all books, whether their name starts with 'myPrefix' or not. The output I would expect is: -- {( "myPrefix-v1", "myPrefix-v2" )} ------ Should I be using a different predicate to retrieve Book objects with the names "myPrefix-v1" and "myPrefix-v2"? Regards, Alex On Sep 8, 2009, at 7:08 PM, Melissa J. Turner wrote: On Sep 8, 2009, at 18:03, Alex Reynolds wrote: Relationship fault for (), name Book, isOptional 1, isTransient 0, entity Owner, renamingIdentifier Book, validation predicates ( ), warnings ( ), versionHashModifier (null), destination entity Book, inverseRelationship Owner, minCount 0, maxCount 0 on Owner < 123456 | username > That's not an error, it's an unfired to-many relationship fault. If you call a method on it (say [testFetchResults valueForKey:@"name"]) it will fire and look more like what you're expecting. BTW, it's generally a bad idea to use uppercase key names. The ivar 'Book' should probably be 'books', and 'Owner' should be 'owner' (the class names are fine the way they are). +Melissa ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data fetch with to-many relationship
Hi Melissa, Thanks for the name change suggestion. When I log the test fetch results: NSArray *testFetchResults = [managedObjectContext fetchObjectsForEntityName:@"Owner" withPredicate:[NSString stringWithFormat:@"ANY books.name like 'myPrefix*'"]]; NSLog([[(Owner *)[testFetchResults objectAtIndex:0] books] valueForKey:@"name"]); I get the following sample output: -- {( "foo", "bar", "myPrefix-v1", "myPrefix-v2" )} -- These were the four test Book objects I originally associated with one Owner, and then saved to the managed object context. I'm unclear why the predicate statement: @"ANY books.name like 'myPrefix*'" would return all books, whether their name starts with 'myPrefix' or not. The output I would expect is: -- {( "myPrefix-v1", "myPrefix-v2" )} -- Should I be using a different predicate to retrieve Book objects with the names "myPrefix-v1" and "myPrefix-v2"? Regards, Alex On Sep 8, 2009, at 7:08 PM, Melissa J. Turner wrote: On Sep 8, 2009, at 18:03, Alex Reynolds wrote: Relationship fault for (), name Book, isOptional 1, isTransient 0, entity Owner, renamingIdentifier Book, validation predicates ( ), warnings ( ), versionHashModifier (null), destination entity Book, inverseRelationship Owner, minCount 0, maxCount 0 on Owner < 123456 | username > That's not an error, it's an unfired to-many relationship fault. If you call a method on it (say [testFetchResults valueForKey:@"name"]) it will fire and look more like what you're expecting. BTW, it's generally a bad idea to use uppercase key names. The ivar 'Book' should probably be 'books', and 'Owner' should be 'owner' (the class names are fine the way they are). +Melissa ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Core Data fetch with to-many relationship
I am having trouble fetching results with a to-many relationship and would like to ask for advice. I have two NSManagedObject subclasses: Owner and Book. There is a one- to-many relationship between Owner and Book (an Owner can be associated with many Books). @interface Owner : NSManagedObject { } @property (nonatomic, retain) NSString * ownerId; @property (nonatomic, retain) NSString * displayName; @property (nonatomic, retain) NSSet* Book; @interface Owner (CoreDataGeneratedAccessors) - (void)addBookObject:(Book *)value; - (void)removeBookObject:(Book *)value; - (void)addBook:(NSSet *)value; - (void)removeBook:(NSSet *)value; @interface Book : NSManagedObject { } @property (nonatomic, retain) NSNumber * type; @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) NSDate * creationDate; @property (nonatomic, retain) Owner * Owner; I first create the Owner managed object instance: Owner *ownerMO = (Owner *)[NSEntityDescription insertNewObjectForEntityForName:@"Owner" inManagedObjectContext:moc]; [ownerMO setOwnerId:[libraryOwner _id]]; [ownerMO setDisplayName:[libraryOwner _displayName]]; NSError *error; [moc save:&error]; I then loop through my Books and add them: for (LibraryBook *libraryBook in libraryBooks) { Book *bookMO = (Book *)[NSEntityDescription insertNewObjectForEntityForName:@"Book" inManagedObjectContext:managedObjectContext]; [bookMO setName:[libraryBook _name]]; [bookMO setCreationDate:[libraryBook _creationDate]]; [ownerMO addBucketObject:bookMO]; NSError *error; [moc save:&error]; } So far, so good (I think). Let's say, in my example, I populate the store with one Owner: Owner < 123456 | username > and multiple Books, some of which have names that start with "myPrefix". When I go to search the Owner entities for Books that start with "myPrefix", I get an error message when I try to look at the results: NSArray *testFetchResults = [managedObjectContext fetchObjectsForEntityName:@"Owner" withPredicate:[NSString stringWithFormat:@"ANY Book.name like 'myPrefix*'"]]; NSLog(@"testFetchResults - \n%d...@\n%@", [testFetchResults count], [testFetchResults description], [(Book *)[(Owner *)[testFetchResults objectAtIndex:0] Book] description]); Here's the error: Relationship fault for (), name Book, isOptional 1, isTransient 0, entity Owner, renamingIdentifier Book, validation predicates ( ), warnings ( ), versionHashModifier (null), destination entity Book, inverseRelationship Owner, minCount 0, maxCount 0 on Owner < 123456 | username > Is the following NSPredicate incorrect for doing a to-many lookup: @"ANY Book.name like 'myPrefix*'" Or did I go about adding new Book and Owner managed objects incorrectly, in that the relationship between Book objects and Owner was not established correctly? Sorry if this is a noob Core Data question. Thanks for your advice. Regards, Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
subclassing with conditional method overriding
Let's say I have a class interface and implementation, as follows: --- @interface A : NSObject { ... } - (void) handleTask; @end @implementation A ... - (void) handleTask { // do stuff specific to A object type... } --- Let's say I then subclass A and override -handleTask: --- @interface B : A { ... } - (void) handleTask; @end @implementation B ... - (void) handleTask { // do stuff specific to B object type... } --- If I instantiate a variable of type B, is there a way to conditionally use the -handleTask method from either class A or B? For example, by casting to (A *) when calling -handleTask? Apologies in advance, if this is a dumb question. Thanks for your advice. -Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSString -initWithData:encoding returning nil
I have the following method, which digests a string with the SHA-1 algorithm: - (NSString *) HMACSHA1DigestWithSecretKey:(NSString *)secretKey { unsigned char digest[CC_SHA1_DIGEST_LENGTH]; char *keyCharPtr = strdup([secretKey UTF8String]); char *dataCharPtr = strdup([self UTF8String]); printf(" HMACSHA1DigestWithSecretKey: \n\tkeyCharPtr -- \n%s\n\tdataCharPtr -- \n%s\n", keyCharPtr, dataCharPtr); CCHmacContext hctx; CCHmacInit(&hctx, kCCHmacAlgSHA1, keyCharPtr, strlen(keyCharPtr)); CCHmacUpdate(&hctx, dataCharPtr, strlen(dataCharPtr)); CCHmacFinal(&hctx, digest); NSData *encryptedStringData = [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH]; NSLog(@" HMACSHA1DigestWithSecretKey: \n\tencryptedStringData -- \...@\n", [encryptedStringData description]); NSString *encryptedString = [[[NSString alloc] initWithData:encryptedStringData encoding:NSUTF8StringEncoding] autorelease]; NSLog(@" HMACSHA1DigestWithSecretKey: \n\tencryptedString -- \...@\n", encryptedString); free(keyCharPtr); free(dataCharPtr); return encryptedString; } However, the step: NSString *encryptedString = [[[NSString alloc] initWithData:encryptedStringData encoding:NSUTF8StringEncoding] autorelease]; returns nil. Here's a sample transcript. I'm trying to digest a test-case key and data from the RFC 2202 docs (cf. http://www.faqs.org/rfcs/rfc2202.html): HMACSHA1DigestWithSecretKey: keyCharPtr -- Jefe dataCharPtr -- what do ya want for nothing? HMACSHA1DigestWithSecretKey: encryptedStringData -- HMACSHA1DigestWithSecretKey: encryptedString -- (null) Why would the call to -initWithData:encoding (the "encryptedString" variable) fail? Thanks for your advice. Regards, Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
How to use NSString with CommonCrypto HMAC correctly?
I am trying to use the HMAC SHA-1 components of Apple's CommonCrypto library with NSStrings, and I am running into some difficulty. I have the following method: - (NSString *) hmacSha1:(NSString *)key data:(NSString *)data { unsigned char digest[CC_SHA1_DIGEST_LENGTH] = {0}; char *keychar = (char *)malloc([key length]); char *datachar = (char *)malloc([data length]); strcpy(keychar, [key UTF8String]); strcpy(datachar, [data UTF8String]); CCHmacContext hctx; CCHmacInit(&hctx, kCCHmacAlgSHA1, keychar, strlen(keychar)); CCHmacUpdate(&hctx, datachar, strlen(datachar)); CCHmacFinal(&hctx, digest); NSData *encStrD = [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH]; NSString *encStr = [NSString base64StringFromData:encStrD length: [encStrD length]]; free(keychar); free(datachar); return [[[NSString alloc] initWithString:[NSString base64StringFromData:encStrD length:[encStrD length]]] autorelease]; } My key is derived from text entered into a UITextField. I call its - text method, which returns a NSString instance. Problem: When I pass in the NSString "key" from this UITextField, the value of "digest" is wrong. (I have a JavaScript utility that I can use to calculate correct digests, for verification purposes.) Workaround: If I manually set "key" inside the method, then "digest" is computed correctly: - (NSString *) hmacSha1:(NSString *)key data:(NSString *)data { key = @"here_is_my_secret_key_blah_blah_blah"; ... } Steps to troubleshoot: I have two lines in this method (not shown) that log the bytes and length of the key: NSLog(@"hmacSha1secretKeyB: %@", [[NSData dataWithBytes:keychar length:strlen(keychar)] description]); NSLog(@"hmacSha1secretKeyL: %d", strlen(keychar)); I have other similar log statements that show the bytes and length of the digest. The strange thing is that the key bytes that are logged are identical, whether the key's NSString value comes from the UITextField -text method call, or whether I use key = @"..." Nonetheless, when the key comes from the UITextField, the digest is wrong. When the key is manually set, the digest is correct. Why would manually assigning a value to the key variable resolve this issue? I apologize if this is a dumb question. I have been tearing my hair out to get this working. Thanks for any advice. Regards, Alex NB. Please ignore the NSString helper method that does base 64 encoding, which I have tested separately. The values that I need to test are actually the digest, not the base 64 encoding, which comes after. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Getting NSTimer to work after an NSThread completes?
On Oct 7, 2008, at 1:42 AM, Jason Coco wrote: [[NSRunLoop mainRunLoop] addTimer:myNSTimer forMode:NSDefaultRunLoopMode]; Thanks for the quick response. Unfortunately, this did not work. The 'myNSTimer' never fires. As a workaround, I tried to update the new view with: [NSThread detachNewThreadSelector:@selector(updateView) toTarget:self withObject:nil]; but this only works for one subview animation. After that, any subsequent detachNewThreadSelector: selector calls never happen. -Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Getting NSTimer to work after an NSThread completes?
When I press my interface button, it calls: [NSThread detachNewThreadSelector:@selector(initializeData) toTarget:self withObject:nil]; This calls: - (void) initializeData { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; ... initialize data ... [[NSNotificationCenter defaultCenter] postNotificationName:DataAreInitializedNotification object:self]; [pool release]; } The notification 'DataAreInitializedNotification' instantiates and brings a new view to the foreground, immediately after the data are initialized. The new view shows up fine. The problem is that if I instantiate an NSTimer in this new view, the NSTimer never fires my selector: [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(doSomethingInteresting:) userInfo:nil repeats:NO] However, if I skip the NSThread instantiation step, then my NSTimer starts working again. I have also tried: [[NSRunLoop currentRunLoop] addTimer:myNSTimer forMode:NSDefaultRunLoopMode]; in my new view, but this does not work either. What should I do to get an NSTimer to work after an NSThread completes? Thanks, Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
CGLayer questions
Is it possible to take a CGLayer and turn it into a bitmap representation? Also, is it possible to grab a CGRect "subset" of a CGLayer and append that to a new CGLayer, so that it isn't necessary to recalculate the entirety of a new CGLayer? Thanks, Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: BOOL array
BOOL vs. bool aside (as well as a couple methods that return NSString* and throw NSException) I wanted to take a stab at making this particular class more portable. If I wrote it closer to the C++ STL spec, I could more easily use it in other contexts while writing my larger application in Cocoa (well, Cocoa Touch, but I guess I can't really say that). I also wanted to learn a bit about Objective-C++. What are the issues that involve exceptions? I find that NSExceptions I have in my larger application still work when I poke those. I did set up something like: -- #include ... try { std::vector *myTestVector = new std::vector(numOfElements, emptyElement); } catch(std::bad_alloc &exc) { NSLog(@"%@", exc.what()); } ... delete myTestVector; -- but I haven't pressure tested it with, say, 100 million elements to see if it cracks. I do run into lots of compilation errors if I don't rename all of my Cocoa classes to *.mm. But otherwise, the application compiles fine and I seem to be able to use all the ObjC syntax I'm used to. I apologize if these are dumb questions. I appreciate all the advice. -Alex Kyle Sluder wrote: On Mon, Sep 15, 2008 at 5:43 PM, Alex Reynolds <[EMAIL PROTECTED]> wrote: Are there any downsides to creating Cocoa-based applications in Objective C++? If you're switching to Objective-C++ just to get std::vector, I would strongly suggest you reconsider. There are plenty of issues regarding ObjC++ in the legacy runtime, particularly involving exceptions. Is there a reason you chose to make such a radical change instead of just using CFBitVector? --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: BOOL array
> > Of course there's always std::vector< bool > ;-) usually at 1 bit per > bit... > > -- > Scott Ribe > [EMAIL PROTECTED] > http://www.killerbytes.com/ > (303) 722-0567 voice Thanks for the tip. So I ended up going the route of making my .m files into .mm files, and using std::vector< vector > to store vectors of vector's. I found that iterator and const_iterator did not work on vector or vector objects. I grabbed vector.size() in order to loop over the vector. Is there a difference in the underlying storage between vector and vector? Is it really a vector of single bits or a vector of larger data? Are there any downsides to creating Cocoa-based applications in Objective C++? Thanks, Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSUInteger in for-loop?
Thanks all for your quick insight! -Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSUInteger in for-loop?
The %lu with casting seems to run into the same issue as %u: ... 2008-09-14 21:43:07.241 NSUIntTest[19779:10b] NSUInteger: 2 2008-09-14 21:43:07.259 NSUIntTest[19779:10b] NSUInteger: 1 2008-09-14 21:43:07.260 NSUIntTest[19779:10b] NSUInteger: 0 2008-09-14 21:43:07.261 NSUIntTest[19779:10b] NSUInteger: 4294967295 2008-09-14 21:43:07.262 NSUIntTest[19779:10b] NSUInteger: 4294967294 ... Interesting. -Alex On Sep 14, 2008, at 9:38 PM, j o a r wrote: NSUInteger runs from 0 -> NSUIntegerMax. This is how you print a NSUInteger: NSLog(@"NSUInteger: %lu", ((unsigned long)counter)); j o a r ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSUInteger in for-loop?
Interesting: ... 2008-09-14 21:38:56.311 NSUIntTest[19750:10b] NSUInteger: 2 2008-09-14 21:38:56.329 NSUIntTest[19750:10b] NSUInteger: 1 2008-09-14 21:38:56.341 NSUIntTest[19750:10b] NSUInteger: 0 2008-09-14 21:38:56.344 NSUIntTest[19750:10b] NSUInteger: 4294967295 2008-09-14 21:38:56.344 NSUIntTest[19750:10b] NSUInteger: 4294967294 2008-09-14 21:38:56.346 NSUIntTest[19750:10b] NSUInteger: 4294967293 2008-09-14 21:38:56.354 NSUIntTest[19750:10b] NSUInteger: 4294967292 ... I will say that the NSLog was done for this particular example, just to see what's going on. The loop otherwise keeps rolling along, with or without an NSLog, %d or %u. Going without an NSLog is how I initially found out about this issue, in that my program would run into other problems related to this loop going past its bounds. -Alex On Sep 14, 2008, at 9:31 PM, Nathan Kinsinger wrote: On Sep 14, 2008, at 10:15 PM, Alex Reynolds wrote: NSLog(@"NSUInteger: %d", counter); The correct type modifier for unsigned integers is %u not %d. Switch it and try again to see what's really happening. --Nathan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSUInteger in for-loop?
I'm wondering if I'm using unsigned integers (specifically NSUInteger) properly or not. I was under the impression that unsigned integers run from 0 to MAX_INT, but when I use them in a "for" loop within these bounds, the loop does not seem to always obey these constraints. For example: for (NSUInteger counter = 5; counter >= 0; --counter) { NSLog(@"NSUInteger: %d", counter); } keeps running well after the "counter" variable turns negative: 2008-09-14 21:03:12.056 NSUIntTest[19579:10b] NSUInteger: 5 2008-09-14 21:03:12.059 NSUIntTest[19579:10b] NSUInteger: 4 2008-09-14 21:03:12.063 NSUIntTest[19579:10b] NSUInteger: 3 2008-09-14 21:03:12.068 NSUIntTest[19579:10b] NSUInteger: 2 2008-09-14 21:03:12.072 NSUIntTest[19579:10b] NSUInteger: 1 2008-09-14 21:03:12.077 NSUIntTest[19579:10b] NSUInteger: 0 2008-09-14 21:03:12.081 NSUIntTest[19579:10b] NSUInteger: -1 2008-09-14 21:03:12.085 NSUIntTest[19579:10b] NSUInteger: -2 ... However, the following does *not* run, starting from a negative integer (as I would expect): for (NSUInteger counter = -5; counter <= 0; ++counter) { NSLog(@"NSUInteger: %d", counter); } Also, the following works properly: for (NSUInteger counter = 0; counter <= 5; ++counter) { NSLog(@"NSUInteger: %d", counter); } I noticed that "uint" works the same way. Is this expected behavior? Thanks, Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
BOOL array
I am currently putting 320 to 480 character long NSString * instances into an NSMutableArray. The characters are 0 or 1. I guess I could use an int array, but I'm looking to speed up my app and reduce storage. Is it possible to create a BOOL array that can be put into an NSMutableArray? Thanks, Alex ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]