Password authentication
Mike- I have hacked together a brief sample app illustrating how I prefer to do password authentication. It does not use the keychain, which can be useful as well. If it's of any interest or use, feel free. It's called MyAuthenticator, which is the first thing listed on the page below. If I understood your goal, you wanted the user to authenticate themselves to the program (via a password) so you could reveal other, sensitive data? If so, this does just that. http://www.ascendiac.com/macosx.html Best Regards, Dan ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Password authentication
Jens- You are absolutely correct, and I should have been more clear. The authenticated part is simply so you can provide feedback to the user. (Your password was wrong.) Replacing the password file could (assuming you knew the process) allow one to achieve authenticated status, but the decrypted 256 bit number would not be a valid key for the encrypted data thereafter. Any sensitive information should be encrypted with the 256 bit key, since it will be unreadable without the correct password file _as well as_ the correct password. Regards, Dan On Feb 13, 2014, at 5:58 PM, Jens Alfke wrote: On Feb 13, 2014, at 2:28 PM, Daniel Wambold wambo...@gmail.com wrote: I have hacked together a brief sample app illustrating how I prefer to do password authentication. It does not use the keychain, which can be useful as well. If it's of any interest or use, feel free. It's called MyAuthenticator, which is the first thing listed on the page below. If I understood your goal, you wanted the user to authenticate themselves to the program (via a password) so you could reveal other, sensitive data? If so, this does just that. It doesn't provide much security, though. Although reading the password file is harmless (because it's been hashed), the file can be _replaced_ with one created by the attacker that matches a password they know. Then they can log in. Also, unless the underlying sensitive data is encrypted, an attacker could grope into the app's data directory and read it. To use this kind of password-based symmetric-key encryption securely, the _data_ to be protected has to be encrypted. So once the user's entered the password and you've derived an AES key from it, you use that key to decrypt the data file. If the decryption results in invalid data, the password was wrong. —Jens ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Confused by memory issue with UIDatePicker
Dear List, I am using manual retain count memory management (started long before ARC was available) for an iOS app. I have a UIDatePicker in an .xib file with its File's Owner set to a custom class, MyTimeDatePickerVC. The MyTimeDatePickerVC inherits from UIViewController, and has an IBOutlet attached to the UIDatePicker. The MyTimeDateVC instance is created in code, in response to a button tap: MyTimeDatePickerVC *myTimeDatePickerVC = [[[MyTimeDatePickerVC alloc] initWithVoucherType:VoucherTimeTypeSurgery andInitialTimes:myInitialTimesDict] autorelease]; [self.navigationController pushViewController:myTimeDatePickerVC animated:YES]; The entire view is dismissed in response to a button tap in its view: [self.navigationController popViewControllerAnimated:YES]; However, if I don't specifically release the UIDatePicker object in the view controller's dealloc, it leaks. If I include [myTimeDatePickerUIOutlet release] in dealloc, it doesn't leak and it works fine. My question is: why should I be releasing this object at all? Or, should I explicitly be creating it somewhere, but I'm not, so the runtime is creating it for me as a courtesy (seems unlikely)? There's a UITableView in the same view (with a corresponding IBOutlet in the same ViewController header), but I don't create or release that explicitly. What have I missed? Do these pickers get treated differently for some reason? (Should I also be releasing the UITableView? The UIButtons?) Thanks for any insight. Best Regards, Dan ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Confused by memory issue with UIDatePicker
Sorry, I should have been more precise: The problem is progressive memory growth each time the ViewController is displayed. If I add the [release], the memory footprint reverts to its pre-viewcontroller display level each time the VC is dismissed. -Dan ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Confused by memory issue with UIDatePicker
Quincey Morris wrote: I have a UIDatePicker in an .xib file with its File's Owner set to a custom class, MyTimeDatePickerVC. The MyTimeDatePickerVC inherits from UIViewController, and has an IBOutlet attached to the UIDatePicker. What does the IBOutlet declaration for the UIDatePicker look like? @interface MyTimeDatePickerVC : UIViewController UITableViewDelegate, UITableViewDataSource { IBOutlet UIDatePicker *myTimeDatePickerUI; The connection is shown in the margin as the circle with a central dot, as expected, and on inspection, it shows it's connected to the MyDateTimePickerVC~iphone's Picker. -W ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Confused by memory issue with UIDatePicker
Kyle Sluder k...@ksluder.com wrote: On Sun, Jun 16, 2013, at 05:00 PM, Daniel Wambold wrote: Quincey Morris wrote: I have a UIDatePicker in an .xib file with its File's Owner set to a custom class, MyTimeDatePickerVC. The MyTimeDatePickerVC inherits from UIViewController, and has an IBOutlet attached to the UIDatePicker. What does the IBOutlet declaration for the UIDatePicker look like? @interface MyTimeDatePickerVC : UIViewController UITableViewDelegate, UITableViewDataSource { IBOutlet UIDatePicker *myTimeDatePickerUI; The connection is shown in the margin as the circle with a central dot, as expected, and on inspection, it shows it's connected to the MyDateTimePickerVC~iphone's Picker. From Managing Nib Objects in iOS, in the Legacy Patterns section of the Nib Files chapter of the Resource Programming Guide http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/1051i-CH4-SW19: As it rebuilds the object hierarchy, UIKit reestablishes connections between the objects using setValue:forKey:, which uses the available setter method or retains the object by default if no setter method is available. This means that (assuming you follow the pattern shown above) any object for which you have an outlet remains valid. For this reason, that document recommends you use a weak declared property for outlets to non-top-level objects. You should probably follow that recommendation. --Kyle Sluder Indeed, I should. Thank you for pointing me to this document, Kyle. Best regards, -Dan ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Confused by memory issue with UIDatePicker
On Jun 16, 2013, at 9:08 PM, Quincey Morris wrote: On Jun 16, 2013, at 17:29 , Kyle Sluder k...@ksluder.com wrote: For this reason, that document recommends you use a weak declared property for outlets to non-top-level objects. You should probably follow that recommendation. Under the circumstances, since this is a manual RR app, just releasing the UIDatePicker [ivar] in dealloc might be a superior approach. If the UIDatePicker is a *top-level* object in the nib, the IBOutlet needs to be a strong reference -- unless there is some other guarantee that it will outlive the nib itself. If it's not a top-level object, then the lifetime of whatever is keeping it alive needs to be considered instead. In either case, using a strong reference seems more robust, since it doesn't involve reasoning about the lifetime dependences, at the slight cost of an explicit release. For what it's worth, the Apple doc went on to say, for legacy memory management (I feel so old!): For iOS, you should use: @property (nonatomic, retain) IBOutlet UserInterfaceElementClass *anOutlet; Then: You should then either synthesize the corresponding accessor methods, or implement them according to the declaration, and (in iOS) release the corresponding variable in dealloc. I did this, with a @synthesize up front and an explicit release in the dealloc. Instruments shows the favorable return of memory when the UI is popped. Thanks again for the assistance! -Dan ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Windows cryptography
Hello. I have an iPhone app (SDK 4.3) that uses symmetric key encryption (AES 256, through the CommonCrypto library). I have the parameters set to use pkcs7 padding, and an iv of all zeros (CBC mode). My question (somewhat off the lists's topic, I'm afraid) is that I need to help our IT people get a file encrypted in this format on a Windows system. I was wondering if anyone has accomplished this task. I strongly prefer that they use open-source code (or something from a major developer, but it'll have to be free, then) if possible, for obvious security reasons, but they don't seem to be able to compile stuff, so I'm hoping to find an open source project that comes with a precompiled binary. Any thoughts? Thanks for any help you might provide! -Dan___ 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: Windows cryptography
OpenSSL is available for Windows, but I can't see how to feed it an encryption key, just a passphrase which is (apparently) converted to a key. However, since CommonCrypto's CCCrypt uses the key directly, that's what I've got. I'll check Cygwin out. Thanks. (Anyone know how to feed OpenSSL a key rather than a passphrase, or at least how to take a passphrase and generate the key?) -Dan___ 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: Windows cryptography
Hello. After further pain, I found the solution: openSSL allows -K (for the key in hex) and -iv (for the initialization vector in hex). (BOTH must be supplied if -K is used.) Consider this thread closed. Thanks to those who assisted. -Dan___ 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: NSTableView Column Header Restrictions?
OK, first, thanks to Quincey for pointing out the document on KVO/KVB key requirements. Since I've made several mistakes along the way, I figured I'd ask if this seems adequate to ensure conversion of arbitrary strings (keyboard entered) into compliant keys. The code subsequently checks to ensure that, after the conversion, they keys are non-nil and not duplicates of existing keys. The pre-conversion string is limited to 30 characters, so I think the maximum these could end up being is something like 90 or 120 characters, given that the percent-conversion can add at least 2 characters to each one they replace. Have I missed anything important? As it is, the NSObject's bind:... method seems to take care of white space by encapsulating the key in quotation marks, but since that violates the key formation rules, I don't want to rely on that behavior. However, since it worked, I didn't realize I was making a mistake, so let me know if I've missed something else. Thanks for your input! (Incidentally, I chose the percent-escape route because it took care of the ASCII conversion and the white space elimination in one shot. Otherwise, I could have gone with a routine to strip white space, convert to data with ASCII, then back to a string, but the keys are only seen by the program, so I figured the percent format wouldn't hurt.) -Dan // // Prepare the column title string for KVO work: Must be non-cap (initial char), ASCII, and non-white-space-containing. myKVOCompliantKey = [myTableColumnTitleUnstripped stringByReplacingOccurrencesOfString:@. withString:@]; myKVOCompliantKey = [myKVOCompliantKey lowercaseString]; myKVOCompliantKey = [myKVOCompliantKey stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]; // End of string prep. // ___ 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: NSTableView Column Header Restrictions?
Previous problem solved: A few weeks ago, I posted a question pertaining to trouble I was having when tableView column header cell titles contained period (.) characters. After working around it, I recently discovered the source of my problem and I figured I'd post just in case anyone else stumbled down this same path. In brief, I have an NSTableView to which the user can add user-titled columns. I bound the tableView's columns to a controller programmatically. This was the root of my trouble. I chose to use the column title strings as the keys for the binding, like this: code [aTableColumn bind:@value toObject:myDataController withKeyPath:[NSString stringWithFormat:@arrangedObjects.%@, [myTitleArray objectAtIndex:i]] options:nil]; /code Of course, when the %@ in the formatted string was replaced with a column title containing a period, the key acquired an incorrect dot-syntax appendage. For whatever reason, that error then caused several messages regarding object validation to occur, convincing me that I had accidentally requested object validation. In any event, the error was entirely mine, and periods can easily coexist with column titles as long as I do something like [[myTitleArray objectAtIndex:i] stringByReplacingOccurrencesOfString:@. withString:@]. -dan___ 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
Apparent NSTableView Bug
I have run up against an apparent 10.6.2 bug in the NSTableView object. Specifically, if NSTableViewSelectionHighlightStyleNone is set, the tableView causes Assertion failures and other problems. Below is some code demonstrating the problem. In any event, I need to emulate the None style for highlight in my TableView. Does anyone know how to set the highlight color, perhaps, to clearColor or something with a tiny alpha value so it approximates the None appearance? I can live with undocumented changes, as the program will run on a system with a fixed OS, and I can un-hack the NSTableView when the problem is repaired. (Radar ID# 7588256). If I've done something wrong and this code is the problem, please tell me, as I'm sort of stuck for now. Thanks! -Dan Sample code: create a new Cocoa project, drag a tableView into IB, wire it to your controller. When you add a row, click on the header, then on the tableView cell. If you comment out the highlightStyle line, this aberrant behavior disappears. @implementation MArrayCont - (void)awakeFromNib { mColTitles = [[NSArray arrayWithObjects:@One, @Two, nil] retain]; NSArray *mCols = [myTableView tableColumns]; int i=0; for (NSTableColumn *aCol in mCols) { [aCol bind:@value toObject:self withKeyPath:[NSString stringWithFormat:@arrangedObjects.%@, [mColTitles objectAtIndex:i]] options:nil]; i++; } [myTableView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone]; } - (IBAction)add:(id)sender { NSMutableDictionary *mNewRow = [[[NSMutableDictionary alloc] init] autorelease]; int i=[[self content] count]; // Just provides some uniqueness to each entry. for (NSString *aColTitle in mColTitles) { [mNewRow setObject:[NSString stringWithFormat:@%i: %@,i, aColTitle] forKey:aColTitle]; } [self addObject:mNewRow]; } - (void)dealloc { [mColTitles release]; [super dealloc]; } @end___ 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: Apparent NSTableView Bug
Corbin- Looks like [myTableView setAllowsColumnSelection:NO]; stopped the crashing for now (I'm sure I've made plenty of other mistakes that are lurking in the dark) Thanks for the tip! -dan___ 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
NSTableView Column Header Restrictions?
I have an NSTableView that I populate with columns programmatically. I use the following to establish the header titles: NSTableHeaderCell *myGenericHeaderCell = [[[NSTableHeaderCell alloc] initTextCell:myTableColumnTitle] autorelease]; [myGenericHeaderCell setAlignment:NSCenterTextAlignment]; [myGenericHeaderCell setEditable:NO]; [myGenericHeaderCell setSelectable:NO]; [aTableColumn setHeaderCell:myGenericHeaderCell]; From there, I add the column to the tableView. My problem is that, if I use a header name that contains a period (.), the tableView tries to validate my data. Is this expected behavior? I have no validation routines anywhere in the program or in IB, and I can only seem to work around this by changing the column names. I can't find this behavior referenced in the NSTableView or NSTableHeaderCell docs. Thanks. -Dan___ 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: NSTableView Column Header Restrictions?
On Jan 19, 2010, at 3:30 PM, Daniel Wambold wrote: I have an NSTableView that I populate with columns programmatically. I use the following to establish the header titles: NSTableHeaderCell *myGenericHeaderCell = [[[NSTableHeaderCell alloc] initTextCell:myTableColumnTitle] autorelease]; [myGenericHeaderCell setAlignment:NSCenterTextAlignment]; [myGenericHeaderCell setEditable:NO]; [myGenericHeaderCell setSelectable:NO]; [aTableColumn setHeaderCell:myGenericHeaderCell]; From there, I add the column to the tableView. My problem is that, if I use a header name that contains a period (.), the tableView tries to validate my data. Is this expected behavior? I have no validation routines anywhere in the program or in IB, and I can only seem to work around this by changing the column names. I can't find this behavior referenced in the NSTableView or NSTableHeaderCell docs. There are no such restrictions. Can you post a backtrace of when it is being validated when you don't expect it to be? There must be something else going on. ...corbin The modal sheet claiming An error occurred, with Discard changes and OK buttons appears with this trace: #0 0x7fff88491e3a in mach_msg_trap #1 0x7fff884924ad in mach_msg #2 0x7fff87bb87a2 in __CFRunLoopRun #3 0x7fff87bb7c2f in CFRunLoopRunSpecific #4 0x7fff87fa6a4e in RunCurrentEventLoopInMode #5 0x7fff87fa6853 in ReceiveNextEventCommon #6 0x7fff87fa670c in BlockUntilNextEventMatchingListInMode #7 0x7fff84f061f2 in _DPSNextEvent #8 0x7fff84f05b41 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] #9 0x7fff84ecb747 in -[NSApplication run] #10 0x7fff84ec4468 in NSApplicationMain #11 0x130f5 in main at main.m:13 If I allow my endEditing timer to fire, I end up with a separate alert window containing identical text and buttons as the above modal sheet, and this trace: #0 0x7fff88491e3a in mach_msg_trap #1 0x7fff884924ad in mach_msg #2 0x7fff87bb87a2 in __CFRunLoopRun #3 0x7fff87bb7c2f in CFRunLoopRunSpecific #4 0x7fff87fa6a4e in RunCurrentEventLoopInMode #5 0x7fff87fa6853 in ReceiveNextEventCommon #6 0x7fff87fa670c in BlockUntilNextEventMatchingListInMode #7 0x7fff84f061f2 in _DPSNextEvent #8 0x7fff84f05b41 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] #9 0x7fff85140943 in -[NSApplication _realDoModalLoop:peek:] #10 0x7fff8513e4cd in -[NSApplication runModalForWindow:] #11 0x7fff8513b981 in -[NSAlert runModal] #12 0x7fff8515d7ef in -[NSApplication(NSErrorPresentation) presentError:] #13 0x7fff854e2d82 in -[NSWindowController presentError:] #14 0x7fff854c0e15 in -[NSValueBinder _presentDiscardEditingSheetWithError:discardEditingCallback:otherCallback:callbackContextInfo:relatedToBinding:] #15 0x7fff854bfca8 in -[NSValueBinder _handleApplyValueError:forBinding:canRecoverFromErrors:handleErrors:typeOfAlert:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert:] #16 0x7fff854c0809 in -[NSValueBinder _applyObjectValue:forBinding:canRecoverFromErrors:handleErrors:typeOfAlert:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert:] #17 0x7fff854c05b4 in -[NSValueBinder applyDisplayedValueHandleErrors:typeOfAlert:canRecoverFromErrors:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert:] #18 0x7fff854bfb9f in -[NSValueBinder _applyDisplayedValueIfHasUncommittedChangesWithHandleErrors:typeOfAlert:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert:] #19 0x7fff854bf7f1 in -[NSValueBinder validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled:] #20 0x7fff854f083b in -[_NSBindingAdaptor _validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled:bindingAdaptor:] #21 0x7fff854f0746 in -[_NSBindingAdaptor validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled:] #22 0x7fff8540ab7a in -[NSTableView textShouldEndEditing:] #23 0x7fff8508a30c in -[NSTextView(NSSharing) resignFirstResponder] #24 0x7fff84eff07b in -[NSWindow makeFirstResponder:] #25 0x7fff850673cd in -[NSWindow endEditingFor:] #26 0x7fff84f2847f in -[NSView removeFromSuperview] #27 0x7fff85086ca5 in -[_NSKeyboardFocusClipView removeFromSuperview] #28 0x7fff8508b04f in -[NSCell endEditing:] #29 0x1000147ea in -[MyContinuousTableViewDelegate myEndEditing] at MyContinuousTableViewDelegate.m:114 #30 0x100014668 in -[MyContinuousTableViewDelegate myTimerAction:] at MyContinuousTableViewDelegate.m:100 #31 0x7fff86688a39 in __NSFireTimer #32 0x7fff87bb9a58 in __CFRunLoopRun #33 0x7fff87bb7c2f in CFRunLoopRunSpecific #34 0x7fff87fa6a4e in RunCurrentEventLoopInMode #35 0x7fff87fa6853 in ReceiveNextEventCommon #36 0x7fff87fa670c in BlockUntilNextEventMatchingListInMode #37 0x7fff84f061f2 in _DPSNextEvent #38
NSArrayControllers not repopulating after NSPersistentDocument load
Dear List, I have an NSPersistentDocument app using CoreData for storage. I have three NSArrayControllers to mediate between the three Entities in my Model and three NSTableViews. Everything works fine until I load a previously saved file. At that point, the controllers seem to have no content despite the fact that the tables are properly populated. That is, the NSTableView shows data, but po [self arrangedObjects] in GDB shows an empty array. At first I figured it was a timing issue, so I delayed the attempt to manipulate an object (accessed by [[self arrangedObjects] objectAtIndex:0]) with a message delayed by up to several seconds with no improvement. If I force a fetch, I can retrieve the data, but for some reason the controller is not taking care of this on its own. I have verified that the controller automatically prepares content, and it's not fetching lazily, per IB. I'm sure I've missed something obvious, but I'm stuck. I'm not sure if it's relevant, but the value of [self managedObjectContext] is different if I check it in the NSPersistentDocument object immediately after - (BOOL)configurePersistentStoreCoordinatorForURL:(NSURL *)url ofType:(NSString *)fileType modelConfiguration:(NSString *)configuration storeOptions:(NSDictionary *)storeOptions error:(NSError **)error versus later, when my controller tries to manipulate its content. Although I modified the document's load method to investigate this (just a call to super followed by a break point), the same behavior exists even without overriding this method. If the answer is in the Apple Docs, I've missed it because I've read them several times now. Incidentally, the Cannot access contents of an object controller after a nib is loaded section of Core Data Programming Guide looked promising, and fetchWithRequest:merge:error returns YES, but it still doesn't cause the controller to repopulate. I've got perhaps 50 pieces of string data stored in this document, so it's not a volume of data issue, I don't think. Thanks for any insight. -Dan The troublesome code, from my NSArrayController subclass, follows. The object, myNote, is sent, after a brief delay, from the Nib file of another object. I verified it contains a valid NSDate object. - (void) myChangeStartTime:(NSNotification *)myNote { [self setFilterPredicate:nil]; [self rearrangeObjects]; [[[self arrangedObjects] objectAtIndex:0] setValue:[[myNote object] dateValue] forKey:kMyDateBindingKey]; }___ 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: NSArrayControllers not repopulating after NSPersistentDocument load
Quincey- I have not created a controller in code, to my knowledge, so I don't know how I'd have two. (I had, previously, made this error by creating an instantiation of NSDocument in IB, but I realized the error in my ways and cleared that up, I believe, by resetting the File's Owner to the MyDocument subclass. which is not instantiated in IB). I can't see any evidence that I missed any part of fixing that. What I have done is dragged an NSArrayController into the nib file, assigned it to the MyVSController subclass, then wired it to the NSTextView. I used code to create the table columns and bindings. The NSArrayController behaves properly (able to show an array of arrangedObjects, make decisions based on these, etc.) prior to saving the file. I *HAD* tried creating and assigning an NSManagedObjectContext object in IB, but realized that was probably a mistake so I removed it and any reference in code to such a thing. The original code did not include the rearrangeObjects call. I put that in to be certain I wasn't missing something that would trigger a re-filtering, thus revealing contents that were otherwise filtered out. The last line of code is simply a way to set an NSDatePicker in the UI to the last clock time the user had chosen. I didn't bind the NSDatePicker because I wanted to be able to do a number of parameter checks on it before allowing its value to slip into the data store. Nevertheless, I agree that the situation seems to suggest that the File Open (load) method that is being invoked by the NSPersistentDocument is creating a new managed object context that is not being attached to the controller. Despite my efforts to force this issue (such as posting the new MOC in a notification object), it fails. I assume this is because I was using the NSPersistentDocument persistent store assignment method, which occurs before the Nib is reconstituted, meaning that the value is lost in the initialization. I don't know if this is a clue, but I have never been able to get this program to respond to the request for [[NSApp delegate] managedObjectContext]. I DO have a delegate to the Application, but I have not yet done anything with it. Could this be part of the problem? In any event, I appreciate any further insight you or anyone else might have. Thanks again. -Dan___ 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: NSDatePicker 24 hour clock
On Jan 8, 2010, at 3:12 PM, Daniel Wambold wrote: Hello. I have an NSDatePicker (NSTextFieldAndStepperDatePickerStyle) and I need it to display time in a 24-hour time mode. After reading Apple's docs and searching the Web, I can't seem to find a way to make this happen. I have attached an NSDateFormatter in IB and specified 24-hour time (HH:MM), but the program reverts back to a 12-hour clock. I changed my System Preferences to a 24 hour clock, but the NSDatePicker refuses to change. I tried a programmatic formatter: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@HH:mm]; [myDatePicker setFormatter:dateFormatter]; (Also tried [[myDatePicker cell] setFormatter:dateFormatter];) In desperation, I set a loop trying every NSDatePickerElementFlags from 0 to 513. Have I missed something, or is a 24-hour clock not allowed? The program is for use in a location where 24-hour time is mandatory. Thanks for any insight you might have. This works for me. I always want UTC time zone and a 24 hour clock, NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; [dateFormatter setDateFormat:@/MM/dd' 'HH:mm:ss' UTC' ]; mystring = [mystring stringByAppendingString:[dateFormatter stringFromDate:date]]; Where date is an NSDate*. The capital HH should give you 24 hours time, as I understand it. Is it possible that [myDatePicker cell] is failing to see your dateFormatter and is using some default instead? david David- Thanks for your response. It looks like you're formatting an NSString with the date. That's fine, but I want the NSDatePicker itself to show 24 hour time. In other words, the UI element that is the date picker should show, next to its stepper, a 24 hour time, rather than an AM/PM time. That was why I tried telling both the NSDatePicker and the NSDatePickerCell to adopt the NSDateFormatter. If you have achieved this UI setup, I misunderstood your response, and would appreciate it if you would clarify how you formatted the DatePicker widget itself. Thanks! -Dan___ 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: NSDatePicker 24 hour clock
Daniel Wambold (wambo...@gmail.com) on 2010-01-08 6:12 PM said: Hello. I have an NSDatePicker (NSTextFieldAndStepperDatePickerStyle) and I need it to display time in a 24-hour time mode. After reading Apple's docs and searching the Web, I can't seem to find a way to make this happen. I have attached an NSDateFormatter in IB and specified 24-hour time (HH:MM), but the program reverts back to a 12-hour clock. I changed my System Preferences to a 24 hour clock, but the NSDatePicker refuses to change. I tried a programmatic formatter: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@HH:mm]; [myDatePicker setFormatter:dateFormatter]; (Also tried [[myDatePicker cell] setFormatter:dateFormatter];) In desperation, I set a loop trying every NSDatePickerElementFlags from 0 to 513. Have I missed something, or is a 24-hour clock not allowed? The program is for use in a location where 24-hour time is mandatory. Thanks for any insight you might have. Strange. Have you tried in a test app? My app's NSTextFieldAndStepperDatePickerStyle NSDateField follows Sys Pref settings. I did nothing fancy to get that behaviour. Sean Sean- Thanks for your reply. Yes, I tried a sample App. (XCode New Project Cocoa App. Open Xib in IB. Drag DatePicker into window. Build debug. AM/PM. Change System Pref to 24 hour clock. Rebuild debug. Same behavior). However, I really prefer to specify this outside of the System Preferences anyway. Most of us (in the US) are used to AM/PM clocks (so I want the rest of the computer's apps to work in AM/PM), but for this work related project, the time must be military. In any event, I couldn't force a change of behavior in this code-free (at least by me) sample app in 10.6.2 Thanks -Dan___ 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: NSDatePicker 24 hour clock
Sean- I changed the Apple Menu System Preferences Date Time Use a 24-hour clock setting. However, as I mentioned, I'd really prefer not to make this a system-wide change. I just find it odd that there would be no programmatic way to change the NSDatePicker to a 24-hour clock. If there isn't I guess I should request that feature (My test app had nothing at all in code. I simply dragged a datePicker from IB's palate into the stock window. I didn't set any formatting.) Thanks again. -Dan___ 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
NSDatePicker 24 hour clock
Hello. I have an NSDatePicker (NSTextFieldAndStepperDatePickerStyle) and I need it to display time in a 24-hour time mode. After reading Apple's docs and searching the Web, I can't seem to find a way to make this happen. I have attached an NSDateFormatter in IB and specified 24-hour time (HH:MM), but the program reverts back to a 12-hour clock. I changed my System Preferences to a 24 hour clock, but the NSDatePicker refuses to change. I tried a programmatic formatter: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@HH:mm]; [myDatePicker setFormatter:dateFormatter]; (Also tried [[myDatePicker cell] setFormatter:dateFormatter];) In desperation, I set a loop trying every NSDatePickerElementFlags from 0 to 513. Have I missed something, or is a 24-hour clock not allowed? The program is for use in a location where 24-hour time is mandatory. Thanks for any insight you might have. Best Regards, Dan___ 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 can I make an NSTableView update its display on command?
Hello List, I am writing a CoreData app with an entity controller bound to an NSTableView, with the bindings created programmatically. Periodically, the program creates a new NSManagedObject, sets default values, and adds it to the MOC. This works fine. However, the NSTableView does not update its display until I mouse over it. In a given period of time, several objects may have been added, but they do not appear until the pointer enters the NSTableView onscreen. I have tried each of the following, then commented them out when they failed: NSLog (@Have we updated yet?\n); // 1 // [myTableViewOutlet reloadData]; // 2 // [myTableViewOutlet lockFocus]; // [myTableViewOutlet display]; // [myTableViewOutlet unlockFocus]; // 3 // [myTableViewOutlet viewWillDraw]; // 4 // [myTableViewOutlet lockFocus]; [myTableViewOutlet drawRect:[myTableViewOutlet bounds]]; [myTableViewOutlet unlockFocus]; // 5 // [[myTableViewOutlet superview] setNeedsDisplay:YES]; // 6 // [myTableViewOutlet lockFocus]; // NSRect myTableViewNewRowRect = [myTableViewOutlet rectOfRow:([myTableViewOutlet numberOfRows]-1)]; // [myTableViewOutlet drawRow:([myTableViewOutlet numberOfRows]-1) clipRect:myTableViewNewRowRect]; // [myTableViewOutlet unlockFocus]; // 7 // [myTableViewOutlet scrollRowToVisible:([myTableViewOutlet numberOfRows]-1)]; Any hints on how to make this view update itself on command. I realize its deferred updating is probably the result of the runtime trying to be efficient, but these new object events only occur about once every 5 minutes, and the end user is not going to understand why none appear for a while, then a whole bunch suddenly pop into view when they move the mouse. Thanks! -Dan___ 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: How can I make an NSTableView update its display on command?
Sorry. It was NOT the NSTableView's problem. I neglected to add: [[self managedObjectContext] processPendingChanges]; after the NSManagedObject was created. Please disregard the previous post. Best Regards, Dan ___ 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
Cocoa bindings and Core Data
Dear List, I am still learning bindings and CoreData, but I have recently completed another relatively basic program using both these technologies. I learn best by seeing other people's code, so in that vein, I'm posting my source (iCredit is the newer program, but Billing Project also uses these basic technologies) in case anyone else might find it helpful. NB: I'm a hack and may have made stylistic or more serious errors, so these should not be treated as though they teach PROPER programming, just adequate programming! Both programs are designed to help small businesses manage different aspects of account maintenance, billing, and debit/credit extensions. They're MIT-license releases, so if you run a small business, feel free to use them within these relatively benign constraints. Happy Programming! -Dan ( http://www.ascendiac.com/macosx.html )___ 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
Answered: How do I bind ManagedObject's relationships to a view?
I'm posting this simply because I *thought* I had looked through all of Apple's bindings for beginners-style documentation, but hadn't seen this sort of dependent controller setup described. Sorry if it's obvious or redundant In the spirit of (finally) answering my own question (and in case anyone else was baffled by this), I was able to bind successfully the dependent list of authorized users (authUsers), which are person entities to an NSTableView by creating a new NSArrayController in IB, setting its Mode to Entity, its Entity Name to the entity that it would display (in this case, for example, my person entity), then setting the Content SET binding to the NSArrayController that managed the complete account entity, with the Controller Key set to selection, and the model path to authUsers, which was a relationship that is the inverse of a person's account relationship. Then, I could bind the NSTableViewColumn to the new controller by selecting the NSTableViewColumn and setting its Value binding to the new controller, its Controller Key to arrangedObjects, and the model key path to the read-only (synthesized on the fly through code) key path, nameAndID. I haven't tried to use the Content Set binding without creating the dependent controller, so I don't know if that would work in some way by using just the main account controller I have Best Regards, Dan ___ 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 do I bind ManagedObject's relationships to a view?
Hello, List. I am a novice with CoreData and bindings and I've stumped myself with this problem. I have created an xcdatamodel that contains 3 objects: an Account object with a relationship property authorizedUsers, which is a to-many relationship with a Person object. The Person object has a reciprocal to-one relationship (account) with the Account object. I have a table view that shows all the accounts, and which, when I click on a given account, should show, in a separate table view, all the authorized users for that account. The Person object has a read-only variable, nameAndID that concatenates the first name, last name, and ID of the person entity. I feel like I've tried every combination of bind to: and paths already. Right now, I've only been successful by pushing a string into a scroll view with: (from the Account.m file) -(NSMutableString *)authorizedUsersNameID { NSMutableString *myString = [[[NSMutableString alloc] init] autorelease]; NSSet *mySetOfAuthorizedUsers = [self valueForKey:authorizedUsersKey]; int i=0; for (Person *aPerson in mySetOfAuthorizedUsers) { ++i; [myString appendFormat:@%i: %...@\n,i, [aPerson valueForKey:nameAndIDKey]]; } return myString; } And in the view controller object: ... NSEntityDescription *personEntityDescription = [NSEntityDescription entityForName:PersonEntity inManagedObjectContext:moc]; NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; [request setEntity:personEntityDescription]; // Set predicate and sort orderings... NSPredicate *predicate = [NSPredicate predicateWithFormat:@(account == %@), mySelectedAccount]; [request setPredicate:predicate]; NSError *error; NSArray *myAuthorizedUsers = [moc executeFetchRequest:request error:error]; if (myAuthorizedUsers == nil || [myAuthorizedUsers count] == 0) { // This is an error situation, as we should always have at least the account owner as an authorized user. NSLog (@Search error: Authorized account users failed to match any account.); } else { [myAccountUserTextView setString:@];// Clear out the text view. for (NSManagedObject *anAuthorizedUser in myAuthorizedUsers) { [myAccountUserTextView insertText:[anAuthorizedUser valueForKey:nameAndIDKey]]; [myAccountUserTextView insertText:@\n]; } } The problem is that, I also want to bind Transaction objects (same relationships as Person) but they have more information such as dates, amounts, and so forth. I'd much rather do this with bindings than to create strings if it can be done. If you know what sort of settings I need to establish in IB to set this up (such as which bindings and what paths), please take a moment to set me straight. The CoreData test model in IB doesn't do this for me, so I can't crib those settings. I have working, subclassed controllers for each managed entity type, and the data are clearly appearing in the managed object (viz. the above code), so I suspect it's just my binding settings that I've got wrong. Thanks for your insight! -Dan ___ 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
Question about IB, filterPredicate, and bindings
Hello, list. I am a hack programmer, so forgive what is probably an obvious question. I'm working on a core data document based app that uses bindings I've created in IB to control a master / detail interface. Briefly, in XCode's xcdatamodel, there is a Person entity with a name (String) and employee (Bool). I have another entity, Transaction, which has an amount (Decimal) and an operator (Person Relationship). So far, so good. Everything is nicely working with bindings. However, I only want the operator pop-up to display Person entities for which employee == 1 (the predicate that I can build in the xcdatamodel fetch request). I would have thought that, in IB, I should be able to choose the pop- up button binding, set the Content binding to the Person array controller, set the controller key to filterPredicate, and choose the keyPath to be the pre-made fetch called getEmployees that I created in the xcdatamodel. It seems like that would simply limit the content to records that fit the predicate. Needless to say, this doesn't work, since at compile time, the console shows this: 2009-11-14 09:47:15.190 iCredit v0.1[7370:a0f] Binding contentValues of object NSPopUpButton: 0x103328aa0 ignored: Key path (currently bound as arrangedObjects.firstName) needs to have the content key path (filterPredicate.getEmployees) as prefix What should I have done, or can this be achieved with IB at all? I'm not opposed to writing the code to populate the NSPopUpButton object by hand, but bindings seem so right for this purpose that I can't seem to get past this hangup. Thanks for any insight! -Dan ___ 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