Sun Proof Water

by N.Ikegami

Japanese Page

Change History

Table of Contents

About this site

An anesthesiologist who loves programming opened this site for releasing freewares.
Cocoa developing pitfalls I falled in are noted.

Freewares

AtAGlance

Pharmacokinetics simulator for anesthetics.
Interactivity, I was paticular about. Definition of a pharmacokinetic parameter can be wrote in the form of an expression, which will be evaluated in run-time (tiny-DSL). So it has flexibility to be able to take parameters depending on patient attributes.

Mac OS X 10.5 is needed. Checked on MacBook Pro (Intel Core Duo 2GB) + Mac OS X 10.5.1

No warranty. Please use AtAGlance at your own risk.

Version History

Developing note

Cocoa

CoreData

NSManagedObjectContext Undo - When property is changed?

With CoreData I felt happy for being able to avoid implemention of Undo/Redo, but I found it is impossible to know when a property would be recovered by the framework if user Un-Did to delete NSManagedObject(MO). The apple document says that awakeFromInsert or awakeFromFetch is the place for initialization of MO, but each of them can not be used for this situation.

Same problem will be happen when MO does Key-Value-Observing for an object referenced by relation property. There is no chance for restart observing. Following contribution is just about this case:

http://www.cocoabuilder.com/archive/message/cocoa/2006/11/20/174747

The solution is self-observing. Aha!

But I found it does not work when the framework reuses MO which was faulting but not released. In the case, firing fault is not notified and relation property is not changed. So, if you send removeObserver:forKeyPath: in didTurnIntoFault, chance for restarting observation would never come. Releasing self-observating MO does not cause error, so we does not have to send removeObserver:forKeyPath:.

Cleaning NSManagedObject up - relation property of no use

Document says that cleaning-up have to be done in willTurnIntoFault, but when willTurnIntoFault is called relation property is already set to nil. So relation property is of no use for cleaning-up.

When NSManagedObject wakes up - initialization depending on others

We can not initialize MO with other MOs in awakeFromFetch, because awakeFromFetch will be sent not in order and referenced MO may not finished initializing. This may cause error which happend irregulary.

Apple says performSelector:withObject:afterDelay: could be help, but it make a document dirty, even if that is just opend.