TweetFollow Us on Twitter

Puzzle 2: What's on the menu?

Volume Number: 19 (2003)
Issue Number: 8
Column Tag: Puzzle Page

John and Pals' Puzzle Page

Puzzle 2: What's on the menu?

by John A. Vink

Try to solve this programming puzzle before the score drops to zero. The puzzle is presented as a discussion among engineers in a chat room. As the engineers gather information and make suggestions, see if you can find the solution. If you solve the problem before you get to the end of the puzzle, you get the score in the left hand column.

SDK: I love the monotony of a steady paycheck.

Argus: Tell me about it, SDK.

100 ChrisE: OK, under what circumstances does GetNewMBar return nil?

95 BMA: No MBAR resource?

ChrisE: It's there.

90 SDK: Out of memory? Like, really out?

ChrisE: Mac OS X

SDK: Heh, mine runs out of memory all the time.

SDK: I can tell because it gets slower and console gets really talkative.

85 BMA: What's ResError and MemError have to say about it?

80 ChrisE: ResError() is 0; MemError() is 0.

BMA: Your computrons are leaking out of the bottom of the case, you need to plug it up with silicone fittings.

BMA: Is this Tuttle's machine? It's cursed, I tells you!

75 Argus: Resource not linked in?

70 Argus: Can you use GetResource on the MBAR?

ChrisE: Whaddya mean "not linked in"?

Argus: What are you really trying to do? Is the resource really available to your app?

BMA: When you said "it's there", did you look in the executable or in the project to verify?

65 ChrisE: OK, I have one project, two targets. The targets build slightly different ways, but with identical source, resources, etc.

ChrisE: One target builds and runs fine.

60 ChrisE: The other (mostly identical) target gets nil from GetNewMBar.

BMA: You got Resorcerer handy?

55 KeithS: Maybe one target requires a MDEF that isn't present in the other?

Pie R. Square: Why is ResError() 0?

50 ChrisE: I DeRez the .rsrc files in both packages and they're identical.

BMA: Bit for bit?!

45 Argus: Throw in a GetResource('MBAR', x) and see if you get a resource back.

Pie R. Square: They link to the same set of libraries?

ChrisE: OK, what's hex for MBAR? I'm in gdb.

JAV: BaseMaster says: 4D424152

BMA: For the record, print/x "MBAR" in gdb does what you want.

40 BMA: Do you load any other resources before loading the MBAR?

ChrisE: Nope.

35 KeithS: gdb ; br GetMenuBar(); call (int) GetResource ( 'MBAR', 128 ) and see if it works.

ChrisE: GetResource returns 0.

Pie R. Square: And ResErr() is 0?

ChrisE: ResError is 0.

30 Argus: ResError is volatile and can get reset quickly.

25 BMA: Your plist is hosed and your resource file is not being opened at all.

BMA: Diff the plists.

20 KeithS: call (void) PrintResourceChain(1)

BMA: Do the resource files match the app names?

15 ChrisE: Plists differ only in the name of the app, but in the one that's broken, the plist name differs from the name of its app.

BMA: There you go.

ChrisE: In the one that works they match.

ChrisE: Bravo, guys. JAV, write this up.

ChrisE: PrintResourceChain shows my .rsrc isn't there, probably because the plist has the wrong name.

10 KeithS: So CFBundle is failing to open your resource file because it's got your exectuable wrong.

BMA: Well, in your case the file itself has the wrong name, but yes.

5 ChrisE: The file has the same name as the executable, but the plist entry is different. I had changed the name in the target editor but an old name persisted in the plist.

BMA: Oh I see, I got it backwards.

ChrisE: Executes correctly now.

ChrisE: Thanks! Score:

85-100 That was pretty good. 65-80 You must have called a friend on the inside. 45-60 You've been carbonizing your apps like a good developer. 25-40 You see, GetMenuResource is a classic Mac OS API.

Score:

85-100 That was pretty good.

65-80 You must have called a friend on the inside.

45-60 You've been carbonizing your apps like a good developer.

25-40 You see, GetMenuResource is a classic Mac OS API.

0-20 Stick to Cocoa and command line apps.


John A. Vink (aka "JAV") is a software engineer for Apple Computer, Inc. He takes a break in the summer to follow INXS on tour. His pals are a bunch of smart friends scattered throughout the Mac programming landscape. You can contact him at vink@apple.com. (The pals reference makes sense with the "John And Pals' Puzzle Page" title)

 
AAPL
$524.94
Apple Inc.
+5.93
MSFT
$40.01
Microsoft Corpora
-0.39
GOOG
$536.10
Google Inc.
-20.44

MacTech Search:
Community Search:

Software Updates via MacUpdate

VMware Fusion 6.0.3 - Run Windows apps a...
VMware Fusion allows you to create a Virtual Machine on your Mac and run Windows (including Windows 8.1) and Windows software on your Mac. Run your favorite Windows applications alongside Mac... Read more
Tweetbot 1.5.1 - Popular iOS twitter cli...
Tweetbot is a full-featured OS X Twitter client with a lot of personality. Whether it's the meticulously-crafted interface, sounds and animation, or features like multiple timelines and column views... Read more
Mac DVDRipper Pro 4.1.7 - Copy, backup,...
Mac DVDRipper Pro is the DVD backup solution that lets you protect your DVDs from scratches, save your batteries by reading your movies from your hard disk, manage your collection with just a few... Read more
PDFpenPro 6.2 - Advanced PDF toolkit for...
PDFpenPro allows users to edit PDF's easily. Add text, images and signatures. Fill out PDF forms. Merge or split PDF documents. Reorder and delete pages. Even correct text and edit graphics! Create... Read more
PDFpen 6.2 - Edit and annotate PDFs with...
PDFpen allows users to easily edit PDF's. Add text, images and signatures. Fill out PDF forms. Merge or split PDF documents. Reorder and delete pages. Even correct text and edit graphics! Features... Read more
Monolingual 1.5.9 - Remove unwanted OS X...
Monolingual is a program for removing unnecesary language resources from OS X, in order to reclaim several hundred megabytes of disk space. It requires a 64-bit capable Intel-based Mac and at least... Read more
Maya 2015 - Professional 3D modeling and...
Maya is an award-winning software and powerful, integrated 3D modeling, animation, visual effects, and rendering solution. Because Maya is based on an open architecture, all your work can be scripted... Read more
Starcraft II: Wings of Liberty 1.1.1.180...
Download the patch by launching the Starcraft II game and downloading it through the Battle.net connection within the app. Starcraft II: Wings of Liberty is a strategy game played in real-time. You... Read more
Sibelius 7.5.0 - Music notation solution...
Sibelius is the world's best-selling music notation software for Mac. It is as intuitive to use as a pen, yet so powerful that it does most things in less than the blink of an eye. The demo includes... Read more
Typinator 5.9 - Speedy and reliable text...
Typinator turbo-charges your typing productivity. Type a little. Typinator does the rest. We've all faced projects that require repetitive typing tasks. With Typinator, you can store commonly used... Read more

Latest Forum Discussions

See All

Have a Special Dead Trigger 2 Easter Bas...
Have a Special Dead Trigger 2 Easter Basket Full of Goodies, Courtesy of Madfinger Games Posted by Rob Rich on April 18th, 2014 [ permalink ] Dead Trigger 2 | Read more »
Almost All of Playdek’s Library is on Sa...
Almost All of Playdek’s Library is on Sale Right Now, and You Should Check it Out Posted by Rob Rich on April 18th, 2014 [ permalink ] Playdek has released quite a few great iOS ports of board and card games over the years, and now most of them... | Read more »
Zynga Launches Brand New Farmville Exper...
Zynga Launches Brand New Farmville Experience with Farmville 2: Country Escape Posted by Tre Lawrence on April 18th, 2014 [ permalink ] | Read more »
David. Review
David. Review By Cata Modorcea on April 18th, 2014 Our Rating: :: MINIMALISTIC IN A DIFFERENT WAYUniversal App - Designed for iPhone and iPad David is a minimalistic game wrapped inside of a soothing atmosphere in which the hero... | Read more »
Eyefi Unveils New Eyefi Cloud Service Th...
Eyefi Unveils New Eyefi Cloud Service That Allows Users to Share Media Across Personal Devices Posted by Tre Lawrence on April 18th, 2014 [ permalink ] | Read more »
Tales from the Dragon Mountain: The Lair...
Tales from the Dragon Mountain: The Lair Review By Jennifer Allen on April 18th, 2014 Our Rating: :: STEADY ADVENTURINGiPad Only App - Designed for the iPad Treading a safe path, Tales from the Dragon Mountain: The Lair is a... | Read more »
Yahoo Updates Flickr App with Advanced E...
Yahoo Updates Flickr App with Advanced Editing Features and More Posted by Tre Lawrence on April 18th, 2014 [ permalink ] | Read more »
My Incredible Body - A Kid's App to...
My Incredible Body - A Kid's App to Learn about the Human Body 1.1.00 Device: iOS Universal Category: Education Price: $2.99, Version: 1.1.00 (iTunes) Description: Wouldn’t it be cool to look inside yourself and see what was going on... | Read more »
Trials Frontier Review
Trials Frontier Review By Carter Dotson on April 18th, 2014 Our Rating: :: A ROUGH LANDINGUniversal App - Designed for iPhone and iPad Trials Frontier finally brings the famed stunt racing franchise to mobile, but how much does its... | Read more »
Evernote Business Notebook by Moleskin I...
Evernote Business Notebook by Moleskin Introduced – Support Available in Evernote for iOS Posted by Tre Lawrence on April 18th, 2014 [ permalink ] | Read more »

Price Scanner via MacPrices.net

Free HopTo 2.2 Helps Enhance Your Productivit...
The HopTo app helps you do more on your iPad by providing more and easier adaccess to files and documents. Version 2.2 adds Egnyte and HopTo’s Mac OSX File Connector. If you already have the hopTo... Read more
National Distracted Driving Awareness Month:...
As the country recognizes National Distracted Driving Awareness Month, Sprint is reminding wireless consumers to focus on driving while behind the wheel, to not text or email while driving, and to... Read more
13-inch 2.4GHz Retina MacBook Pro available f...
Abt has the 13″ 2.4GHz 128GB Retina MacBook Pro available for $1229 including free shipping. Their price is $70 off MSRP. Read more
iMacs on sale for up to $160 off MSRP this we...
Best Buy has iMacs on sale for up to $160 off MSRP for a limited time. Choose free home shipping or free instant local store pickup (if available). Prices are valid for online orders only, in-store... Read more
iPad Airs on sale this weekend for up to $100...
Best Buy has WiFi iPad Airs on sale for $50 off MSRP and WiFi + Cellular iPad Airs on sale for $100 off MSRP on their online store for a limited time, with prices now starting at $449. Choose free... Read more
Apple restocks refurbished Mac minis starting...
The Apple Store has restocked Apple Certified Refurbished Mac minis for up to $150 off the cost of new models. Apple’s one-year warranty is included with each mini, and shipping is free: - 2.5GHz Mac... Read more
Hyundai Brings Apple CarPlay To The 2015 Sona...
Hyundai Motor America has announced it will bring Apple CarPlay functionality to the 2015 Sonata. CarPlay is pitched as a smarter, safer and easier way to use iPhone in the car and gives iPhone users... Read more
Updated iPads Coming Sooner Than We Had Thoug...
MacRumors, cites KGI securities analyst Ming Chi Kuo, well-respected as an Apple product prognisticator, saying that Apple will introduce an upgraded iPad Air and iPad mini in 2014/Q3, meaning the... Read more
Toshiba Unveils New High And Low End Laptop M...
Toshiba has announced new laptop models covering both the high-end and low-end of the notebook computer spectrum. Toshiba 4K Ultra HD Laptop Toshiba’s new Satellite P55t features one of the world’s... Read more
Save up to $270 with Apple refurbished 13-inc...
The Apple Store has Apple Certified Refurbished October 2013 13″ Retina MacBook Pros available starting at $1099, with models up to $270 off MSRP. Apple’s one-year warranty is standard, and shipping... Read more

Jobs Board

*Apple* Automotive Parts Department position...
Apple Automotive is one of the fastest growing dealer…and it shows. Consider making the switch to the Apple Automotive Group today! At Apple Automotive, we Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Retail - Manager - Holyoke - Apple I...
Job Summary Keeping an Apple Store thriving requires a diverse set of leadership skills, and as a Manager, you’re a master of them all. In the store’s fast-paced, Read more
*Apple* Retail - Manager - Apple (United Sta...
Job SummaryKeeping an Apple Store thriving requires a diverse set of leadership skills, and as a Manager, you're a master of them all. In the store's fast-paced, dynamic Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.