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
$111.78
Apple Inc.
-0.87
MSFT
$47.66
Microsoft Corpora
+0.14
GOOG
$516.35
Google Inc.
+5.25

MacTech Search:
Community Search:

Software Updates via MacUpdate

LibreOffice 4.3.5.2 - Free Open Source o...
LibreOffice is an office suite (word processor, spreadsheet, presentations, drawing tool) compatible with other major office suites. The Document Foundation is coordinating development and... Read more
CleanApp 5.0.0 Beta 5 - Application dein...
CleanApp is an application deinstaller and archiver.... Your hard drive gets fuller day by day, but do you know why? CleanApp 5 provides you with insights how to reclaim disk space. There are... Read more
Monolingual 1.6.2 - 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
NetShade 6.1 - Browse privately using an...
NetShade is an Internet security tool that conceals your IP address on the web. NetShade routes your Web connection through either a public anonymous proxy server, or one of NetShade's own dedicated... Read more
calibre 2.13 - Complete e-library manage...
Calibre is a complete e-book library manager. Organize your collection, convert your books to multiple formats, and sync with all of your devices. Let Calibre be your multi-tasking digital librarian... Read more
Mellel 3.3.7 - Powerful word processor w...
Mellel is the leading word processor for OS X and has been widely considered the industry standard since its inception. Mellel focuses on writers and scholars for technical writing and multilingual... Read more
ScreenFlow 5.0.1 - Create screen recordi...
Save 10% with the exclusive MacUpdate coupon code: AFMacUpdate10 Buy now! ScreenFlow is powerful, easy-to-use screencasting software for the Mac. With ScreenFlow you can record the contents of your... Read more
Simon 4.0 - Monitor changes and crashes...
Simon monitors websites and alerts you of crashes and changes. Select pages to monitor, choose your alert options, and customize your settings. Simon does the rest. Keep a watchful eye on your... Read more
BBEdit 11.0.2 - Powerful text and HTML e...
BBEdit is the leading professional HTML and text editor for the Mac. Specifically crafted in response to the needs of Web authors and software developers, this award-winning product provides a... Read more
ExpanDrive 4.2.1 - Access cloud storage...
ExpanDrive builds cloud storage in every application, acts just like a USB drive plugged into your Mac. With ExpanDrive, you can securely access any remote file server directly from the Finder or... Read more

Latest Forum Discussions

See All

Make your own Tribez Figures (and More)...
Make your own Tribez Figures (and More) with Toyze Posted by Jessica Fisher on December 19th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
So Many Holiday iOS Sales Oh My Goodness...
The holiday season is in full-swing, which means a whole lot of iOS apps and games are going on sale. A bunch already have, in fact. Naturally this means we’re putting together a hand-picked list of the best discounts and sales we can find in order... | Read more »
It’s Bird vs. Bird in the New PvP Mode f...
It’s Bird vs. Bird in the New PvP Mode for Angry Birds Epic Posted by Jessica Fisher on December 19th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Telltale Games and Mojang Announce Minec...
Telltale Games and Mojang Announce Minecraft: Story Mode – A Telltale Games Series Posted by Jessica Fisher on December 19th, 2014 [ permalink ] | Read more »
WarChest and Splash Damage Annouce Their...
WarChest and Splash Damage Annouce Their New Game: Tempo Posted by Jessica Fisher on December 19th, 2014 [ permalink ] WarChest Ltd and Splash Damage Ltd are teaming up again to work | Read more »
BulkyPix Celebrates its 6th Anniversary...
BulkyPix Celebrates its 6th Anniversary with a Bunch of Free Games Posted by Jessica Fisher on December 19th, 2014 [ permalink ] BulkyPix has | Read more »
Indulge in Japanese cuisine in Cooking F...
Indulge in Japanese cuisine in Cooking Fever’s new sushi-themed update Posted by Simon Reed on December 19th, 2014 [ permalink ] Lithuanian developer Nordcurrent has yet again updated its restaurant simulat | Read more »
Badland Daydream Level Pack Arrives to C...
Badland Daydream Level Pack Arrives to Celebrate 20 Million Downloads Posted by Ellis Spice on December 19th, 2014 [ permalink ] | Read more »
Far Cry 4, Assassin’s Creed Unity, Desti...
Far Cry 4, Assassin’s Creed Unity, Destiny, and Beyond – AppSpy Takes a Look at AAA Companion Apps Posted by Rob Rich on December 19th, 2014 [ permalink ] These day | Read more »
A Bunch of Halfbrick Games Are Going Fre...
A Bunch of Halfbrick Games Are Going Free for the Holidays Posted by Ellis Spice on December 19th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »

Price Scanner via MacPrices.net

Kodak Returns to CES With New Consumer Produ...
Former photography colossus Kodak is returning to CES for the first time in three years where the Kodak booth (#21818 South Hall 1) will showcase a wide range of innovative, imaging-related products... Read more
Invaluable Launches New Eponymously -Named A...
Invaluable, the world’s largest online live auction marketplace, hhas announced the official launch of the Invaluable app for iPad, now available for download in the iTunes App Store. Invaluable... Read more
IDC Reveals Worldwide Mobile Enterprise Appli...
International Data Corporation (IDC) last week hosted the IDC FutureScape: Worldwide Mobile Enterprise Applications and Solutions 2015 Predictions Web conference. The session provided organizations... Read more
Hello Vino Wine App Launches “Safe Ride Home”...
Hello Vino has announced addition of a new “Get a Safe Ride Home” feature in its Food & Drink app with a direct connection to Uber, the technology platform that connects users with rides. The... Read more
DEVON-technologies Releases DEVONthink To Go...
Coeur d’Alene, Idaho based DEVON-technologies, LLC has updated DEVONthink To Go, its mobile companion to DEVONthink, to version 1.5. The update includes an iOS 8 extension, compatibility with the... Read more
The Apple Store offering free next-day shippi...
The Apple Store is now offering free next-day shipping on all in stock items if ordered before 12/23/14 at 10:00am PT. Local store pickup is also available within an hour of ordering for any in stock... Read more
It’s 1992 Again At Sony Pictures, Except For...
Techcrunch’s John Biggs interviewed a Sony Pictures Entertainment (SPE) employee, who quite understandably wished to remain anonymous, regarding post-hack conditions in SPE’s L.A office, explaining “... Read more
Holiday sales this weekend: MacBook Pros for...
 B&H Photo has new MacBook Pros on sale for up to $300 off MSRP as part of their Holiday pricing. Shipping is free, and B&H charges NY sales tax only: - 15″ 2.2GHz Retina MacBook Pro: $1699... Read more
Holiday sales this weekend: MacBook Airs for...
B&H Photo has 2014 MacBook Airs on sale for up to $120 off MSRP, for a limited time, for the Thanksgiving/Christmas Holiday shopping season. Shipping is free, and B&H charges NY sales tax... Read more
Holiday sales this weekend: iMacs for up to $...
B&H Photo has 21″ and 27″ iMacs on sale for up to $200 off MSRP including free shipping plus NY sales tax only. B&H will also include a free copy of Parallels Desktop software: - 21″ 1.4GHz... Read more

Jobs Board

*Apple* Store Leader Program (US) - Apple, I...
…Summary Learn and grow as you explore the art of leadership at the Apple Store. You'll master our retail business inside and out through training, hands-on experience, Read more
Project Manager, *Apple* Financial Services...
**Job Summary** Apple Financial Services (AFS) offers consumers, businesses and educational institutions ways to finance Apple purchases. We work with national and Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.