mac sample code