Help with Macintosh programming

macintosh programming, mac programming, mac os programming, mac os x programming, mac programming language, mac programing

Archive for January, 2012

Adding to system preferences?

I’m working on software ported from Linux to
Mac OS X and that runs as a daemon.  I’m fairly
new to the Mac world, but it appears that the right
way to control and configure this daemon is through
System Perferences.  I haven’t found any documentation
on how to add a System Preferences screen.  So my
questions are:

1) Is this possible and the right thing to do?

2) Is there any documentation on how to do this?

3) Are there any tools that help one do this?



posted by admin in Uncategorized and have Comments (8)

Mac OS 8/9 – how to wait and still yield time


I want to make a background application for Mac OS 8 and 9 that does
something ever 5 msec or so, but also allows other apps on the system
to function.  I’d like to structure it like

        do some stuff
        wait 5 msec

where the system and other apps can use my 5 msec.

Also, I’d like to be able to get time even if the mouse button is

Finally, how do I start an application like this (a) before the login
appeares, and (b) so it stays running even if the user logs off?

fred Ross-Perry

posted by admin in Uncategorized and have Comments (3)


Erm, I’m getting an EXC_BAD_ACCESS opening a document, and it seems to
be raised at -[NSMenu performActionForItemAtIndex:].  Any ideas as to
what performActionForItemAtIndex: uses that I might have released

Spike A.

The Hitchhiker’s Guide to the Galaxy, Earth Edition

See Goo.  See Goo Go.  Go Goo, Go.  Goo Goo G’joob.

posted by admin in Uncategorized and have Comments (2)

Applescript Registry and Filemaker

The applescript registry is a Filemaker Pro DB.
Is there a way to access it without me spending a few hundred dollars on
an app I don’t need and CAN’T afford


posted by admin in Uncategorized and have Comment (1)

Casting a class to its subclass

Can I cast a class to one of its subclasses in Obj-C, ie I have a class B
which inherits from class A. I also have a method which is passed a pointer to
a class A how can I do something like this:

-( void )someFunc( A * a )
    [ (B)a aMessage ];


Class B responds to ‘aMessage’ but not A.

I have tried the above but just get "conversion to non-scalar type requested"

Thank you.



posted by admin in Uncategorized and have Comments (5)

Detecting keyboard script

I use GetScriptManagerVariable(smkeyscript) to get a current
keyboard script. But it sometimes reports a wrong value, e.g.
smRoman while keyboard is in smJapanese.

Is there any alternative?

Takehiko Abe

posted by admin in Uncategorized and have No Comments

About memory deallocation of object in Objective-C

In this method

         NSFont *viewer_font = [NSFont fontWithName:@"Monaco" size:9.0];

         [text_viewer_ref setFont:viewer_font];
         [text_viewer_ref setString:[NSString stringWithCString:str]];
         [text_viewer_ref setSelectedRange:NSMakeRange(begin_offset, len)];
         [text_viewer_ref scrollRangeToVisible:NSMakeRange(begin_offset, len)];

   (text_viewer_ref is id for NSTextView)

is memory allocated for NSFont and NSString automaticaly free
after the function terminate (after the caller code goes to the next

This method must be called very often.
How improve the code to make better memory usage ?

Alain Birtz
Internet abz_ANTiSP…, abirtz_ANTiSP…
Remove _ANTiSPaM_ in the email address
Enlever _ANTiSPaM_ dans cette adresse electronique

posted by admin in Uncategorized and have Comments (3)

[Q] The 'GetFileInfo' tool (MacOS X)

In the ‘Developer/Tools’ folder that you get when you install the
development tools provided by apple, there is a tool called GetFileInfo.
How can one make use of this tool?

Thank you.

posted by admin in Uncategorized and have Comments (2)

Quicktime movie creation problems

I’m trying to create a movie from a series of DIBs.  I’ve got it
working so that the DIB is correctly drawn to the offscreen GWorld I
create, and it does produce a proper .mov file with data in it.  When
I play the file though, there is no video.  It does play (the little
thumb moves progresses to the end on the right).  If I look into the
movie properties, the movie lists it’s size as ‘none’ but it does give
a proper duration value (under time).  If I look at the Video Track
heading, it also lists the size as ‘none’, but gives the correct
values for the dimensions and bit depth under format.

Here’s the relevant code.  What am I doing wrong?

Thanks, Rob.

void CQTFile::Open(std::string sFilename, const bazcam::Format&
        m_sFilename = sFilename; = 0;
        m_TrackFrame.left = 0;
        m_TrackFrame.bottom = format.iHeight;
        m_TrackFrame.right = format.iWidth;

        FSMakeFSSpec(0, 0, StdToPascalString(m_sFilename), &m_FSSpec);
        CheckResult(CreateMovieFile(&m_FSSpec, FOUR_CHAR_CODE(‘TVOD’),
                        createMovieFileDeleteCurFile | createMovieFileDontCreateResFile,
&m_ResourceNumber, &m_Movie), "Problem creating movie file.");
        m_VideoTrack = NewMovieTrack(m_Movie, format.iWidth, format.iHeight,
        CheckResult(GetMoviesError(), "Problem creating movie video track.");
        m_VideoMedia = NewTrackMedia(m_VideoTrack, VideoMediaType,
        CheckResult(GetMoviesError(), "Problem creating movie track media.");
        CheckResult(BeginMediaEdits(m_VideoMedia), "Problem entering media
edits mode.");
        NewGWorld(&m_pGWorld, 24, &m_TrackFrame, nil, nil,
        SetGWorld(m_pGWorld, nil);
&m_TrackFrame, 0, codecNormalQuality, kAnimationCodecType,
                static_cast<CompressorComponent>(anyCodec), &m_MaxCompressedSize),
"GetMaxCompressionSize error");
        m_hCompressedData = NewHandle(m_MaxCompressedSize);
        CheckResult(MemError(), "NewHandle error");
        m_pCompressedData = StripAddress(*m_hCompressedData);
        m_ImageDesc = reinterpret_cast<ImageDescriptionHandle>(NewHandle(4));
        CheckResult(MemError(), "NewHandle error");
        m_bOpen = true;


void CQTFile::Close(void)
        if (m_ImageDesc) {
        if (m_hCompressedData) {
        if (m_pGWorld) {
        short int iResourceId = movieInDataForkResID;
        CheckResult(EndMediaEdits(m_VideoMedia), "Problem stopping media
edits mode.");
        int mediaDuration = GetMediaDuration(m_VideoMedia);
        CheckResult(InsertMediaIntoTrack(m_VideoTrack, 0, 0, mediaDuration,
fixed1), "Error inserting media into track.");
        CheckResult(AddMovieResource(m_Movie, m_ResourceNumber, &iResourceId,
StdToPascalString(m_sFilename)), "Error adding movie resource.");
        if (m_ResourceNumber)    {
        DisposeMovie (m_Movie);
        m_bOpen = false;


void CQTFile::AddBitmapToMovie(SDIB DIB)
        PicHandle hPic = GetPICTFromDIB(DIB.hBitmap);
        CheckResult(DrawTrimmedPicture(hPic, &m_TrackFrame, nil,
suppressDither, nil), "Error drawing picture to offscreen buffer.");
        DWORD err = GetLastError();
        CheckResult(CompressImage(GetGWorldPixMap(m_pGWorld), &m_TrackFrame,
                kAnimationCodecType, m_ImageDesc, m_pCompressedData), "CompressImage
error" );
        err = GetLastError();
        CheckResult(AddMediaSample(m_VideoMedia, m_hCompressedData, 0,
(**m_ImageDesc).dataSize, 60,
                reinterpret_cast<SampleDescriptionHandle>(m_ImageDesc), 1, 0, nil),
"AddMediaSample error" );
        err = GetLastError();

- — -


posted by admin in Uncategorized and have Comments (2)

Sending audio over a modem

Is it possible to dial a phone number and send audio over the phone line
in OS X?  I’m not even sure if a modem is capable of sending audio.


posted by admin in Uncategorized and have Comments (8)