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)

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Combo Quest (Games)
Combo Quest 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: Combo Quest is an epic, time tap role-playing adventure. In this unique masterpiece, you are a knight on a heroic quest to retrieve... | Read more »
Hero Emblems (Games)
Hero Emblems 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: ** 25% OFF for a limited time to celebrate the release ** ** Note for iPhone 6 user: If it doesn't run fullscreen on your device... | Read more »
Puzzle Blitz (Games)
Puzzle Blitz 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Puzzle Blitz is a frantic puzzle solving race against the clock! Solve as many puzzles as you can, before time runs out! You have... | Read more »
Sky Patrol (Games)
Sky Patrol 1.0.1 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.1 (iTunes) Description: 'Strategic Twist On The Classic Shooter Genre' - Indie Game Mag... | Read more »
The Princess Bride - The Official Game...
The Princess Bride - The Official Game 1.1 Device: iOS Universal Category: Games Price: $3.99, Version: 1.1 (iTunes) Description: An epic game based on the beloved classic movie? Inconceivable! Play the world of The Princess Bride... | Read more »
Frozen Synapse (Games)
Frozen Synapse 1.0 Device: iOS iPhone Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: Frozen Synapse is a multi-award-winning tactical game. (Full cross-play with desktop and tablet versions) 9/10 Edge 9/10 Eurogamer... | Read more »
Space Marshals (Games)
Space Marshals 1.0.1 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.1 (iTunes) Description: ### IMPORTANT ### Please note that iPhone 4 is not supported. Space Marshals is a Sci-fi Wild West adventure taking place... | Read more »
Battle Slimes (Games)
Battle Slimes 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: BATTLE SLIMES is a fun local multiplayer game. Control speedy & bouncy slime blobs as you compete with friends and family.... | Read more »
Spectrum - 3D Avenue (Games)
Spectrum - 3D Avenue 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: "Spectrum is a pretty cool take on twitchy/reaction-based gameplay with enough complexity and style to stand out from the... | Read more »
Drop Wizard (Games)
Drop Wizard 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Bring back the joy of arcade games! Drop Wizard is an action arcade game where you play as Teo, a wizard on a quest to save his... | Read more »

Price Scanner via MacPrices.net

Apple’s M4 Mac minis on sale for record-low p...
B&H Photo has M4 and M4 Pro Mac minis in stock and on sale right now for up to $150 off Apple’s MSRP, each including free 1-2 day shipping to most US addresses. Prices start at only $469: – M4... Read more
Deal Alert! Mac Studio with M4 Max CPU on sal...
B&H Photo has the standard-configuration Mac Studio model with Apple’s M4 Max CPU in stock today and on sale for $300 off MSRP, now $1699 (10-Core CPU and 32GB RAM/512GB SSD). B&H also... Read more

Jobs Board

All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.