Erica Sadun


Erica Sadun. iPhone. iPod touch. Macintosh. and More.

Sample Code

Erica Sadun | 2:09 pm | October 8, 2008 | 2.1, Books, Admin

Sample Code. Please let me know if everything works okay and whether I messed up anything in the uploads. Of course, also let me know where the code has issues. I’m still reviewing C6-C10 for 2.1 compatibility. Feel free to use the issues page to report issues

56 Comments »

Comment by fgrios | October 9, 2008 | 3:19 pm

I just bought your ebook and have started reading it. I have not ventured through the whole book yet as I am excited to get started. I have been playing with the various SDK incarnations for a while, but not really done any real work.

I noticed on page 23, that template selection picture is different from my installation (using the latest SDK). Should I be selecting a “Window-based application” template in the new SDK to match what you are doing in the book?

Also, will there be updates to the ebook that more closely reflect the current state of the development environment? I recognize that it is a moving target and a decision has to be made, but I am curious as to the update policy on the ebook. Some companies update their ebooks rather frequently while others don’t.

Thank you for your help in advance.


Comment by dom | October 9, 2008 | 10:01 pm

Excellent book. Having a hard time though in the CF example trying to get a standard tile flip like in iTunes. How can I make it so the view created in requestFlipLayerAtIndex doesn’t disappear after the flip? I’d be infinitely grateful for any pointers!


Comment by Erica Sadun | October 10, 2008 | 7:35 am

You need to provide another view like I do in the Safari Books Online Bookbag app. After the “flip”, add the subview and remove on “re-flip”. The flip gives just enough visual continuity that it’s clear that you’re revealing or hiding another UI component


Comment by Erica Sadun | October 10, 2008 | 2:00 pm

We can’t really update the book but I’m making sure the sample code is fresh.


Comment by dom | October 11, 2008 | 5:11 am

Got it working — thanks a lot.


Comment by darpandalal | October 11, 2008 | 6:44 am

hi erica first of all great work with coverflow how do i add images instead of colours ??


Comment by Erica Sadun | October 11, 2008 | 7:35 pm

Plug in the image you want to use in the coverFlow: requestImageAtIndex: quality: datasource method


Comment by chitgoks | October 14, 2008 | 3:57 am

hi erica, im reading your book. still in the early parts. im a bit confused with this provisioning. there is a part in the book that says, apple allows developers to distribute iphone apps outside the app store via ad hoc distribution. but this still means that i need to apply for a developer program right? im thinking since it’s ad hoc distribution, i can create a provision profile for free. you can email me if you want. thank you


Comment by dom | October 14, 2008 | 6:17 am

Another CF question if I may, I want to add a layer from a UILabel to the images I’ve passed to requestImageAtIndex. I can do this for the images that are initially visible but can’t figure out how to get at the rest of them. Is this possible / would any of the methods in the header file be useful for this purpose? Many thanks.


Comment by Erica Sadun | October 14, 2008 | 7:43 am

To put an app on an iPhone, any app phone, you must pay the $99 tax, whether for ad hoc, regular distribution or testing.

Dom: You can just use standard core graphics calls for the layer but I’m not sure to what degree sublayers are used here.


Comment by merkelct | October 14, 2008 | 6:59 pm

Just bought your book a a day ago and wanted to say thanks and I look forward to reading it and that you are a life saver I have an app that needs to be built by the end of the month


Comment by Neo | October 16, 2008 | 8:00 am

Hi Erica,

Thank-you so much for creating book. I’ve always wanted to build specialized apps for the iPhone. I am just starting the book. I’m not sure if this is the right place to post the following. Please let me know if it belongs somewhere else.
I’ve followed your instructions for the Hello World app in chapter one. I set the iPhone Simulator version to 2.1 and then “Build & Go”. The app is successfully created on the Simulator then launched. The helloworld.png image is displayed, however, shortly thereafter the app crashes. In the debugger console, the following error shows up:

[Session started at 2008-10-16 09:24:01 -0400.]
2008-10-16 09:24:01.928 HelloWorld[3651:20b] Unknown class HelloWorldAppDelegate in Interface Builder file.
2008-10-16 09:24:01.929 HelloWorld[3651:20b] Unknown class HelloWorldViewController in Interface Builder file.
2008-10-16 09:24:01.930 HelloWorld[3651:20b] *** Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: ‘[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key window.’

Is this possibly due to the 2.1 environment?

Thanks again,
Randy


Comment by Erica Sadun | October 16, 2008 | 8:19 am

Make sure you deleted all the xibs and removed the two lines from Info.plist


Comment by Neo | October 16, 2008 | 8:21 am

Please disregard my earlier question. It is answered. There is a Sample Code “1a” that I neglected to use which runs flawlessly.


Comment by mozart27 | October 16, 2008 | 6:15 pm

Hey Erica,

I am really enjoying your book on the iPhone. I’ve read other stuff but your’s is great.

I have found what I *think* are one or two minor typos/errors. Where can I send this info to help you?

thanks!

jb


Comment by brickLayer | October 17, 2008 | 3:05 am

Hi. Thanks a lot for the example. They are not that easy to find so far.

I was wondering if it would be possible to instead of having the flip go away from the screen and whatever info you want to display just popping up, how you would go about reversing the flip so that it comes toward the screen instead of away and then returns back. The ability to scale would be even better.

Thanks.


Comment by brickLayer | October 17, 2008 | 6:52 am

Oh. Also this is giving me problems. I’m transitioning from a normal view to this cover flow view based on shouldAutorotateToInterfaceOrientation in the main controller. If I return YES it is oriented correctly after I rotate the phone. If I return NO it is an up and down rotation no matter the orientation of the phone. I don’t mind having this return YES other than the fact that the status bar goes all white and sticks around when I do that. Whereas if I return no the status bar thing doesn’t happen. Is there some way I can rotate the whole cover flow view in the event that I return NO so that it is at the right orientation? I’m confused by the fact that from the example I have no access to any of the 3d stuff here.


Comment by Neo | October 17, 2008 | 9:26 am

Hi Erica,

In the DragMultipleViewsPersistent Sample Code (3b), the following UIApplication (Extended) interface functions are declared:

-(void) _writeApplicationSnapshot;
-(void) _updateDefaultImage;
-(void) createApplicationDefaultPNG;

However, only _writeApplicationSnapshot is called when the app terminates (in the current sample code). The image attributes are saved during app termination and are preserved when the app is relaunched as required. What is the use of the functions _updateDefaultImage and createApplicationDefaultPNG if the same results are achieved? Is it due to efficiency? I can see launching the last screen capture being faster than recalculating location attributes then re-drawing.

Thanks for your help.

Randy


Comment by brickLayer | October 17, 2008 | 5:10 pm

Actually I don’t need help with that white bar thing when going to landscape.. However I’m still not understanding why when I rotate one way coverflow shows up upside down.


Comment by pm200107 | October 21, 2008 | 1:53 pm

Hi erica,

tx for your book!! I was a bit disappointed as I was expecting more for audio part. You tell that celestial can be addressed via the mediaplayer fw. I used to use celestial with the avitem, avcontroller nd avqueue. I had 3 remote mp3 in the queue and I could use the playnextitem or resume (in case of bad net connection). It seems now, that queuing is a bit more confusing, and play next queue item is not mentioned in your book, neither is the resume method. What about it? could it be possible to have an update of your code sample (C7 part II) with those thing? As I did not know celestial could be addressed, I was trying to use the AudioStream option which is not as easy as celestial was. Why don’t you mentioned this possibility? just because no one is using it? How do people stream mp3 with their appstore app? any sample could be posted for that part?

Once again, so many thanx for the book.

pm


Comment by matt | October 29, 2008 | 11:34 am

Hi Erica,

The only gripe I have is that the code is quite hard to follow with it all being in the one .m file.

This goes against what I’ve been taught and come to expect. Is it a big job to split the code into .h and .m files for each view/controller?

Great book, though!

Thanks,
matt


Comment by Erica Sadun | October 29, 2008 | 11:38 am

Matt: It’s a lot easier to show a single point in one file than in 7. I stand behind the decision.


Comment by matt | October 29, 2008 | 12:42 pm

I think I see what you mean, however I do think this approach will confuse many people as it is so different to what you expect. Anyway…

The other issue I have is when trying to build to my device I am getting 0xE800003A (error verifying application). I have change the Bundle Identifier in the Info.plist, which is all that I usually have to do when compiling sample code.

Should I be doing anything else to get it to build to a device?


Comment by Erica Sadun | October 29, 2008 | 12:45 pm

Make sure your provision is properly set and that your target build settings match your project build settings


Comment by matt | October 29, 2008 | 12:53 pm

Thank you. There was no value for “Code Signing Identity” in Target Build Info.


Comment by bearc0025 | October 30, 2008 | 8:19 pm

Hi Erica,
Thanks for all the great ideas and inspiration on various sites. I tried your AVRecorder code from TUAW and cdn’t get the activate call to work (return non-zero).
I just bought your book and was sad to see the use of Audio Queue recording (but Celestial stuff for playback). Does it only work for playback now?
Keep up the great work!


Comment by Erica Sadun | October 30, 2008 | 8:28 pm

bearc: I cannot comment because of the NDA. (Yes, there’s still one — just different.) Hop over to Apple’s site for deets.


Comment by ervedge | November 2, 2008 | 11:59 pm

C02 - Views.zip would not expand…
any prior complaints?
Erv


Comment by ervedge | November 3, 2008 | 12:01 am

hummmb

Sorry to report: “C02 - Views.zip” would not expand after download… just bought paperback of book
Any other complaints? (C01 unpacked fine)
Thanks
Erv Edge


Comment by Erica Sadun | November 3, 2008 | 8:36 am

Erv: Try re-downloading. Sometimes the files get corrupted by the browser


Comment by lbendlin | November 8, 2008 | 3:09 pm

Is it just me being dumb (always an option) or is the converter code in the book (listing 3.-2) not compatible with SDk2.1? Also, this is supposedly an example about a UIViewController but as far as I can see the Controller is not connected to anything, and the program runs fine without it.

-(void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:contentView] ;
[window makeKeyAndVisible];
}

Can you please help me out of my confusion?


Comment by mwi | November 13, 2008 | 2:39 pm

Thanks for the code. I am slowly making my way through your book. Is there any way to do a callout view from a UIButton? I have tried everything! THANKS. MI


Comment by MrIcee | November 13, 2008 | 5:30 pm

Aloha Erica:

Thanks for the E-book, very good!

Having a small problem with (no kidding) Hello World. Using your C1 folder with the 01a Revised sub-folder. It works fine in the Simulator.

The ONLY changes I’ve made is to provision it for my iPhone. When it uploads to the iPhone, the program runs, but the images don’t display (I get the Hello World banner at the top, and it rotates when flipped, but the ‘world image’ doesn’t appear.

My iPhone (3G) is running 2.1, and I set the Build for 2.1 - could this be why? (is the example using something specific to 2.2?)

Mahalo nui loa


Comment by MrIcee | November 14, 2008 | 11:31 am

Aloha again Erica:

As per my last post about images not making it to the iPhone. I have tried a number of your other examples, all compiling in RELEASE mode for 2.1 (what is installed on my 3G iPhone).

All examples I tried work find in the simulator, and work fine once I provision them on my iPhone EXCEPT the iPhone versions don’t have any images (non image functionality is fine, but images don’t display). Even the HelloWorld app icon in SpringBoard does not display the icon (it displayes only the milky white rounded glossy button effect, with no underlaying images).

I have yet to figure out why. I’m using your xcode project files directly in the chapter example folders (e.g. I’m just double clicking your project file, changing the release and build to 2.1, and adding my provision information).

Can you shed light on why I don’t see images on the iPhone, but I do in the simulator?

Thanks


Comment by DanielBirns | November 14, 2008 | 1:50 pm

Erica,

I’m working with your iPhone book and it’s excellent. I just got done working through the Hillegass book, which is also excellent, and I think the two complement each other. You’ve been criticized for putting all the code in one file. However, I find it enlightening after Hillegass, which works hard to make clear the relationship of IB and Cocoa. However, for the newcomer, IB and the default files that XCode gives you tends to obfuscate what’s really going on, and this is what makes your book wonderful. It focuses on the essentials. IB is not essential, and neither is the file organization, and there’s a lot of mysteries there that are there for convenience and organization, but can make learning harder.

Finally, I find a book written by a woman refreshing. The chapter 2 flowers example would be an unlikely male program. And half of consumers are women, and developers need that perspective.

Thanks! — Daniel


Comment by nhouse | November 29, 2008 | 10:35 pm

I am having some issues with the Chapter 7 part 2 sample code. I am trying to integrate Celestials AVController audio playback into my app and was looking to your sample code for enlightenment. The code compiles and displays through the simulator though pressing start does not initiate playback. I am running XCode 3.1. I would really like to use this to playback streamed audio. Do you think this would be the better way to go?

Thanks,

Nathan


Comment by Erica Sadun | November 30, 2008 | 12:29 pm

You should replace the AVController stuff with the new 2.2 AVFoundation framework.

As for playback, neither will work on the Simulator. The iPhone has the proper codecs for playback.


Comment by timd | December 4, 2008 | 11:55 am

First of all I apologize if this is a novice question. I am learning Objective C and Cocoa Touch at the same time as a hobby…

What I would like you to clarify is how you have NO nib or xib files in your sample code? Are you not using Interface builder?


Comment by gowreck | December 4, 2008 | 3:40 pm

erica-

First, your book is the best resource for the iphone by far - no joke. Its been immensely helpful to me. I do have a question about the multitouch demo application. If I create two instance of the MultiTouchView in the ViewController is it possible to have them both be listening for the touch?

After some playing I deteremined that I could add bringViewToFront when touchBegins and sendViewToBack when touchEnds but that means I have to click the first one before I can access the second one. I’m making the uneducated assumption that this because the view is being set to the entire window in drawRect:?

Any thoughts would be greatly appreciated.


Comment by Erica Sadun | December 4, 2008 | 5:24 pm

IB is a utility, not a requirement. Chapter 3 has an IB walkthrough. Keep in mind that as fabulous as IB is, it’s still really in development and wasn’t available for a good portion of the time I was writing the book and when it did debut remained buggy and preliminary.


Comment by petersjc | December 15, 2008 | 9:08 pm

Erica,
Just bought the book, but as a Noob I’m already having a difficult time with even the first Hello World 1a code sample using the build/run in Xcode tool.
I get an error message “Code Sign error: Code signing identity: ‘iPhone Developer’ does not match any code-signing certificate”, and, o course it won’t run. Pls advise.
P.S. In all the examples I have seen in the book, you don’t use the .h and .m files (except for main()), the use of the .m and .h files are very common in other books on the iPhone code examples. Can U clarify? Does this mean that all you example recipies in the book only go into the Main.m file?


Comment by Erica Sadun | December 16, 2008 | 12:32 pm

Follow the instructions in Chapter 1 and on Apple’s portal site to sign with your own credentials.


Comment by panda123 | December 19, 2008 | 11:30 am

Chapter 6 covers a framed table which I want to try to use, expand upon to use with an image rather than table. However where does the code make the centre portion of the image cutbg.png transparent?


Comment by Erica Sadun | December 19, 2008 | 11:44 am

Translucent PNGs for the win. No code needed.


Comment by panda123 | December 19, 2008 | 11:57 am

Ding Dong!!! I looked up how to do this in GIMP and it works :) Thanks so much!


Comment by panda123 | December 29, 2008 | 10:52 am

Hi Erica, Happy Holidays!

Was not sure to email you direct or ask here?

I have run the code in Ch8 re animate a button I am trying to make this work in my app.

Imagine a viewport with an imageview displaying an image inside it. Each time the user taps the image rotates to the next image, 25 in all and this works.

I then want to add animation and thought of a thread but found your code re animationimages.

I set the current image array in viewDidLoad and when anomation is required I call the method to assign to the existing visible UIImageView the animationimages, duration etc. but it does not work.

Even debugging thru the code show it runs but nothing happens on screen I even tried using setneedsdisplay to force refresh but nothing?

Is it not possible to set animations to an pre existing visible UIImageView?

Thanks


Comment by orangelca | January 11, 2009 | 10:24 am

Hi Erica,

Wonderful book on the iPhone SDK, I bought the book as I was looking for a solutions on how to send stream video to a iPhone, but I can´t see anything that will help me achieve this goal… can you help me on how to, what to read, any sample code.. etc.

Thanks in advance for your response.


Comment by nikihana | January 26, 2009 | 5:39 pm

Hi Erica,

I am reading your wonderful book - thanks!
I ran across this site from one of your postings describing enabling bonjour on the iPhone. As I pursued that link, it quickly led me nowhere….Do you know where I can find the sources for picsend and piclisten?

Thanks.


Comment by Erica Sadun | January 26, 2009 | 5:43 pm

This is the original source code that I borrowed from:
http://developer.apple.com/samplecode/PictureSharingBrowser/index.html


Comment by dirkdk | February 3, 2009 | 11:49 am

hi erica,

thanks for the book.

I am struggling to get through the IB walkthrough in chapter 3, using SDK 2.2 (figure 3.1-3.9). Also I see your (probably updated) sample code does not 100 % reflect the book. Very probable to the updates of IB and the SDK, but kind of annoying as I am trying now for 2 days in vein to get it running. Would it be too much to ask you to revisit the walkthrough and post an update, for example in PDF form?

tia, dirk


Comment by panda123 | April 13, 2009 | 2:18 pm

HI Erica, can you throw some light on how to stop the UIActivityIndicatorView animation?

I start it in a new thread, then start my long process in a new thread which then stops the animation running.

But I am finding the animation stops and disappears long before the long processing finishes?

I have also treid putting the stop animation outside in main thread but no joy?


Comment by dlee1976 | July 26, 2009 | 8:52 pm

Hi Erica,

Great book!

I’m just having a little trouble for the Recipe: Adding Callout Views. Is it possible to include the class files along with the sample code?

Thanks,
Dave


Comment by dlee1976 | July 26, 2009 | 10:26 pm

Hi again!

I was able to get the UICalloutView Recipe to work! Just one more question. In the recipe you have the UICalloutView.h snippet of code. This is not the same as the actual dump from Steve Nygard. Why is that? I ask because the code worked with yours and not the dump of the header.

Thanks,
Dave


Comment by blacksheep | March 4, 2010 | 4:29 am

hi erica,

i’d like to record the sounds while playing ins my musical insrument apps. and also save them and play them simultaneously when playing new sounds.

i only find tutorials for recording with microphone.
what should i use?

thanks,
blacksheep


Comment by Erica Sadun | March 4, 2010 | 10:00 am

If you’re generating the data that’s getting played, just save that data to a file, no?


Comment by blacksheep | March 5, 2010 | 7:24 am

ah, i thoight i can modify your “record Audio” example. but of course its telling : “no audio input available” on the iPod….

so i have to find out HOW generate the data’s.
i got the hint to make two dimensional arays with time and sound, but must admit that i don’t know how to.
thanks.


Comments RSS.

Leave a comment

You must be logged in to post a comment.

Previous and Next Entry

« Code Sample Videos | Checking in »

wordpress | sheepdip design by mahud © 2007