Life as Clay

Archive for February 2011

Connecting NSOutlineView to Core Data in 10.6 Part 1: Ordered Trees

NOTE: This tutorial is now outdated. I’m leaving it here for posterity, but please know that it may not work.

There are aspects to Cocoa that I find extremely obtuse and difficult to implement. I’m relatively new both to programming and Cocoa, and I suspect that others in the same boat also are frustrated by these steps. The single most frustrating simple thing that I have come across is implementing an NSOutlineView that connects to a Core Data model. There are several ways to approach this problem; primarily with or without Cocoa Bindings and with or without sorting.

There is a good, but outdated tutorial on how to make this work at this link: http://allusions.sourceforge.net/articles/treeDragPart1.php

The primary problem with the tutorials is that it requires the use of private Apple methods, which means that anything you build with it will not be accepted into the Mac App Store. This tutorial draws very heavily on that tutorial, with updated screenshots and code that does not use private APIs. The code also is difficult to read on that page, so it’s updated here in an easier-to-read format. Oh, and one more thing: the example on that page uses a feature of Interface Builder that no longer exists – subclassing within IB.

This tutorial is done with Xcode 3.2.5 on OS X 10.6.6.

The tutorial continues after the break…

Read the rest of this entry »

Written by Clay

February 13, 2011 at 09:31

Advice for new fathers: Your child probably is overstimulated

leave a comment »

Both new mothers and new fathers want to provide a maximum level of comfort for their child. In the first few weeks, this is relatively simple: feed, change diapers, clean (if necessary), lightly entertain, swaddle, protect, etc. Newborns, to a large extent, are passive in these processes. They feed so often that mom’s breast usually both is appropriate and all that is required to pacify them.

After 4-6 weeks, however, babies frequently enter a “fussy period” that can last for several weeks or months. Brazelton writes about this period and says that he warns new parents about it. The warning is because many parents internalize the fussiness and think that it is due to their shortcomings as parents. This probably isn’t the case.

Infants develop a sense for their surroundings pretty quickly, and as their neurons fire, their brains develop, and their physical coordination emerges, their awareness increases dramatically. Most infants have pretty good head and neck control by 6 weeks of age; they look around and soak in many new sights and sounds each day.

The “fussy period” is somewhat like clockwork. Each day, usually in the evening, an infant will begin to cry. There seemingly is nothing that you can do, as a parent, to quiet the child. Brazelton describes this as basically an overflow of stimulation. Your child’s nervous system has absorbed all that it can for the day and the fussy period is a reaction to reaching capacity. These episodes of crying frequently happen around dinner time, sometimes referred to as “the witching hour.”

Here’s what you can do:

  1. You need to make sure that your child’s needs are met. Feed her, change her diaper, and make sure that she is not too warm or cold.
  2. Take your baby into a quiet and dark room, to remove as much stimulation as possible. Be quiet, don’t shake, bounce, walk, sing, etc… you’re trying to remove stimulation, not add more. We frequently think that we’re helping to console babies when, in fact, we are overstimulating them.
  3. Your baby may have gas. Crying can make the gas worse, since infants tend to swallow air when they are screaming. Burp your child (even if she hasn’t recently eaten) and help her work gas out of her belly. There are techniques for this in various books and on the Internet. Get some infant gas drops at the pharmacy — they really seem to help at times.
  4. Hold your child for a few minutes and try to console her. She may continue to scream in your ear.
  5. Swaddle your child — make it snug, but not too tight. I strongly suggest watching the video associated with “The Happiest Baby on the Block.” There are techniques for holding your swaddled infant that will quiet her immediately. Helping her calm down will help you put her down.
  6. After she’s calmed a bit, hold her against your chest, swaddled, and gently pat her on the back and tell her that it’s time to be quiet.
  7. When she’s quiet, put her in her crib (or co-sleeper, bassinet, moses basket, etc…) gently. She may begin to cry again immediately. If she does, repeat step 6. If that doesn’t quiet her, then repeat the sideways swaddle hold from step 5 and then proceed to step 6.
  8. Repeat this process until she remains quiet and/or goes to sleep. It may take 10-15 tries, or even more.
  9. Quietly exit the room. You probably just bought yourself up to 20 minutes of quiet time. Use it. Eat dinner, relax… but be prepared for her to begin to scream again. When she does, you probably need to start at step 2 again, unless she hasn’t eaten for a while or you know that she needs a diaper change.

This can go on for 3-4 hours, sometime longer. You have to remain patient here, however. Neither you nor the baby’s mother are doing anything wrong: it’s just that a normal day of normal life with normal stimulation is a little too much for your baby to handle at this point.

It’s handy to have a pacifier nearby. One thing that you can do is to run it under warm water before giving it to your child. I’ve found that our daughter takes one more readily if it is warm and slightly wet. She usually doesn’t like it, but sometimes, when she is upset, it is the ONLY thing that will calm her down.

The final thing to do here is to reassure the baby’s mother that she’s doing everything properly and is doing a good job of it. Mothers have far stronger hormonal connections to their infants than fathers do. As a father, while you may be able to tolerate crying for extended periods of time, the child’s mother may become really upset by it after seconds or a minute. This is when you need to step in and reassure her that she is doing well and to take some of the burden of caring for the child away from her.

Written by Clay

February 7, 2011 at 09:29