TV getting trashier and trashier

TV getting trashier and trashier

A show I enjoy watching is Rules of Engagement.  I think the writing is good,
but extremely adult and racy.  That seems to be the standard today, get in as many sexual references and jokes about sex as possible.  I like the relationships between the married couple and between the engaged couple, and yes, David Spade is good too.  I really liked Patrick Warburton on Seinfeld and he is terrific as the deadpan husband.  Though I recommend the show for adults, if you aren’t one to blush easily, for goodness sake, don’t let your kids watch it.

Cassidy had asked me to tape Gossip Girl, which I did, and she watched it on her own this week. When I
asked if I should continue taping it for her she mentioned casually
that it was a bit inappropriate (thank goodness). I skimmed the episode
tonight and decided it was not a show for her. I did not realize it was
much worse than I thought. Tracee over at Blog Fabulous explains why it is garbage.  I have decided to
stay away from the CW network, and to never let my kids watch a show
for the first time without supervision.

Archives in Cocoa

Archives in Cocoa

If you need to save and load data from files, and you don’t mind creating binary files (don’t need to read or edit them), then Archives are the simplest way to go.

Load contents of file into an NSArray:

    NSArray* m_ProcessedFiles = [NSKeyedUnarchiver unarchiveObjectWithFile:destPath];

Save contents of array to file:

    [NSKeyedArchiver archiveRootObject:m_ProcessedFiles toFile:srcPath];       

objective-c error message: invalid conversion from ‘objc_object*’

objective-c error message: invalid conversion from ‘objc_object*’

This error message had me stumped for a while:

invalid conversion from ‘objc_object*’ to ‘int’

the line in question was something like this:

int iResult = [MyUtils utilsMemberFunc:param1,param2];

it doesn’t matter what the "to" type is, what is important is that you recognize that this message, in this context, is reporting that the utilsMemberFunc declaration was not found and due to objective-c’s dynamic binding it is assuming it returns an objc_object* rather than the type that utilsMemberFunc was declared to return.  So why isn’t it finding the declaration?  Because I used ‘,’ rather than ‘:’ to separate the parameters.  Besides the fact my brain still thinks in C++, I use commas to separate parameters in a variable list alot ( [NSString stringWithFormat:@"%d,%d", num1, num2]).

Through trial and error and comparing similar code that works it finally dawned on me that my syntax was incorrect.

Problem with breakpoints in Xcode

Problem with breakpoints in Xcode

I'm running Xcode 2.4.1

I have an odd breakpoint problem that I have not seen written about. I can set breakpoints no problem, my program will break correctly. My problem is when I run my program again, though the breakpoints appear marked correctly in the UI and in the breakpoint window, none of the breakpoints break.  Going to the command-line GDB (GNU debugger) via <Option><Apple> (must be in the debugger window) I type in "break info" and it reports no breakpoints!

Don't know what happened in my environment for this to start occuring but it is very inconvenient to re-enter all my breakpoints on each invocation.  I hope I find the problem soon.

Update: I found the "Stop on Debugger()/DebugStr()" command in the Debug window.  This will save me, for now, allowing me to break inside some initialization code which runs before I get a chance to set breakpoints.  I just insert a Debugger(); call in the code where I want to "break".

Update:  Today,  Aug 26, 2008, "xcode breakpoint" is appearing at #1 in Google.  In case you aren't reading the comments to this post,  Aaron's suggestion:

"In xcode go to Preferences, select the page for Debugging then make sure "Load symbols lazily" is NOT selected"

seems to fix many of the breakpoint issues for most people.  It didn't address my particular issue that I described in the post (I think my project has gotten corrupted or something), but it did help me in other instances.


Working with Pascal Strings in Cocoa

Working with Pascal Strings in Cocoa

In trying to access information from a quicktime file I came across my first pascal string (pstring).  Trying to copy this string using strncpy or NSString:stringWithCString did not work so I looked at the memory and saw a number as the first byte.  I recognized this as a pascal string so I searched on conversion from pstring to NSString and found this:

http://www.omnigroup.com/mailman/archive/macosx-dev/2001-August/030492.html
http://developer.apple.com/documentation/CoreFoundation/Reference/CFStringRef/Reference/reference.html#//apple_ref/c/func/CFStringCreateWithPascalString

The documentation for CFString states: "in a method where you see an NSString * parameter, you can pass in a CFStringRef" but the compiler complained so as in the example code linked above, I resorted to using the NSString:stringWithFormat. My first thought was to simply use NSString:stringWithString.

Here is the wrapper function I came up with:

-(NSString*)NSStringFromPString:(unsigned char*) pstring
{
    CFStringRef strRef = CFStringCreateWithPascalString (NULL, pstring, kCFStringEncodingMacRoman);
    return [NSString stringWithFormat:@"%@",strRef];
}

Update 8/24/07: It seems the error when using stringWithString has something to do with what source is being compiled.  If it is in an .mm file (enables C++ compatibility?) I get the error:

error: cannot convert ‘const __CFString*’ to ‘NSString*’ in argument passing

but if compiled in an .m file it works fine.  It appears that in the former case, the compiler is being stricter, though a forced cast will eliminate the error message.

Mac Documentation, not so good

Mac Documentation, not so good

I’ve given the Development Documentation for XCode a few weeks, but yesterday, after spending half a day searching how to retrieve the Codec information from a quicktime file, I finally concluded that the best source of documentation is source code on the web.  With the lack of examples the documentation is only of minimal help when you are new and trying to discover HOW to do things, not just reference information.

Two sites helpful in searching code are Krugle and Koder.  Krugle has a nicer UI. I haven’t used Koder much.