开发者

download iphone sample code from apple [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 9 years ago.

Improve this question

the iphone sdk documentation has links to sample code, but you have to download them individually from the web. Is there a bundle you can download all at once from apple ?

For example, reading the f开发者_StackOverflow社区irst iphone tutorial at switchonthecode, the first new word I came across was UIApplication. There are 5 samples on the web...


I'm a beginner as well and found it annoying they don't have an "all examples" zip. They also don't make it easy to pull them down automatically because they use javascript to populate the list of examples.

Fortunately I was able to use Chrome to inspect the examples page and give me the effective "end result" HTML and used it to create this script which will download and unpack all of the examples.

Hopefully we as a community can keep this list maintained, but as of today it does contain all the examples.

ios-examples.sh

#!/bin/bash

while read n; do
    wget "http://developer.apple.com/library/ios/samplecode/$n/$n.zip" &&
    unzip "$n.zip" &&
    rm "$n.zip"
done <<EOF
AQOfflineRenderTest
AccelerometerGraph
Accessory
AddMusic
AdvancedTableViewCells
AdvancedURLConnections
AlternateViews
AppPrefs
BatteryStatus
BonjourWeb
Breadcrumb
BubbleLevel
CopyPasteTile
CoreDataBooks
CryptoExercise
CurrentAddress
DateCell
DateSectionTitles
DocInteraction
DrillDownSave
EADemo
FastEnumerationSample
Formulaic
GKRocket
GKTank
GKTapper
GLES2Sample
GLGravity
GLImageProcessing
GLPaint
GLSprite
GLTextureAtlas
GenericKeychain
HazardMap
HeaderFooter
HeadsUpUI
HelloWorld_iPhone
Icons
InternationalMountains
KMLViewer
KeyboardAccessory
LaunchMe
LazyTableImages
ListAdder
LocateMe
Locations
MailComposer
MapCallouts
MessageComposer
Metronome
MixerHost
MoveMe
MoviePlayer_iPhone
MultipleDetailViews
MusicCube
NavBar
PVRTextureLoader
PageControl
PhotoLocations
PhotoPicker
Popovers
PrintPhoto
PrintWebView
QuartzDemo
QuickContacts
Reachability
Reflection
Scrolling
SeismicXML
SimpleDrillDown
SimpleEKDemo
SimpleFTPSample
SimpleGestureRecognizers
SimpleNetworkStreams
SimpleURLConnections
SimpleUndo
SpeakHere
SysSound
TableSearch
TableViewSuite
TableViewUpdates
TaggedLocations
Teslameter
TheElements
ToolbarSearch
TopPaid
TopSongs
TouchCells
Touches
Trailers
TransWeb
UICatalog
URLCache
ViewTransitions
WeatherMap
WhichWayIsUp
WiTap
WorldCities
ZoomingPDFViewer
aurioTouch
avTouch
iAdSuite
iPhoneCoreDataRecipes
iPhoneExtAudioFileConvertTest
iPhoneMixerEQGraphTest
iPhoneMultichannelMixerTest
iPhoneUnitTests
oalTouch
EOF

On a related note, I find that ack is a far superior way to search the examples than find/grep

Hope this helps others as much as it helped me.


http://www.jerrybeers.com/index.php/2011/06/18/copying-xcode-samples/ shows how to get all the samples from the existing xcode install on your machine. Very useful!


Thanks to David Blevins for original posted above. I manually looked for any first added's and grep'd David's script adding new stuff hopefully keeping the script up to date:

    #!/bin/bash

# Found here:
# http://stackoverflow.com/questions/2576256/download-iphone-sample-code-from-apple

while read n; do
    wget "http://developer.apple.com/library/ios/samplecode/$n/$n.zip" &&
    unzip "$n.zip" &&
    rm "$n.zip"
done <<EOF
AQOfflineRenderTest
AccelerometerGraph
Accessory
AddMusic
AdvancedTableViewCells
AdvancedURLConnections
AlternateViews
AppPrefs
BatteryStatus
BonjourWeb
Breadcrumb
BubbleLevel
CopyPasteTile
CoreDataBooks
CoreTelephonyDemo
CryptoExercise
CurrentAddress
DateCell
DateSectionTitles
DocInteraction
DrillDownSave
EADemo
ExternalDisplay
FastEnumerationSample
Formulaic
GKAuthentication
GKRocket
GKTank
GKTapper
GLES2Sample
GLGravity
GLImageProcessing
GLPaint
GLSprite
GLTextureAtlas
GenericKeychain
HazardMap
HeaderFooter
HeadsUpUI
HelloWorld_iPhone
Icons
InternationalMountains
KMLViewer
KeyboardAccessory
LaunchMe
LazyTableImages
ListAdder
LocateMe
Locations
MailComposer
MapCallouts
MessageComposer
Metronome
MixerHost
MoveMe
MoviePlayer_iPhone
MultipleDetailViews
MusicCube
MVCNetworking
NavBar
PVRTextureLoader
PageControl
PhotoLocations
PhotoPicker
Popovers
PrintPhoto
PrintWebView
QuartzDemo
QuickContacts
Reachability
Reflection
Scrolling
SeismicXML
SimpleDrillDown
SimpleEKDemo
SimpleFTPSample
SimpleGestureRecognizers
SimpleNetworkStreams
SimpleTextInput
SimpleURLConnections
SimpleUndo
SpeakHere
SysSound
TableSearch
TableViewSuite
TableViewUpdates
TaggedLocations
Teslameter
TheElements
ThreadedCoreData
ToolbarSearch
TopPaid
TopSongs
TouchCells
Touches
Trailers
TransWeb
UICatalog
URLCache
ViewTransitions
WeatherMap
WhichWayIsUp
WiTap
WorldCities
ZoomingPDFViewer
aurioTouch
avTouch
iAdSuite
iPhoneACFileConvertTest
iPhoneCoreDataRecipes
iPhoneExtAudioFileConvertTest
iPhoneMixerEQGraphTest
iPhoneMultichannelMixerTest
iPhoneUnitTests
oalTouch
EOF


For those of you on OSX (and don't have wget/don't want to install it just for this). Plus, it looks like it has moved from http to https:

while read n; do
curl -o $n.zip https://developer.apple.com/library/ios/samplecode/$n/$n.zip
unzip $n.zip &&
rm $n.zip
done <<EOF
AQOfflineRenderTest
AccelerometerGraph
Accessory
AddMusic
AdvancedTableViewCells
AdvancedURLConnections
AlternateViews
AppPrefs
BatteryStatus
BonjourWeb
Breadcrumb
BubbleLevel
CopyPasteTile
CoreDataBooks
CoreTelephonyDemo
CryptoExercise
CurrentAddress
DateCell
DateSectionTitles
DocInteraction
DrillDownSave
EADemo
ExternalDisplay
FastEnumerationSample
Formulaic
GKAuthentication
GKRocket
GKTank
GKTapper
GLES2Sample
GLGravity
GLImageProcessing
GLPaint
GLSprite
GLTextureAtlas
GenericKeychain
HazardMap
HeaderFooter
HeadsUpUI
HelloWorld_iPhone
Icons
InternationalMountains
KMLViewer
KeyboardAccessory
LaunchMe
LazyTableImages
ListAdder
LocateMe
Locations
MailComposer
MapCallouts
MessageComposer
Metronome
MixerHost
MoveMe
MoviePlayer_iPhone
MultipleDetailViews
MusicCube
MVCNetworking
NavBar
PVRTextureLoader
PageControl
PhotoLocations
PhotoPicker
Popovers
PrintPhoto
PrintWebView
QuartzDemo
QuickContacts
Reachability
Reflection
Scrolling
SeismicXML
SimpleDrillDown
SimpleEKDemo
SimpleFTPSample
SimpleGestureRecognizers
SimpleNetworkStreams
SimpleTextInput
SimpleURLConnections
SimpleUndo
SpeakHere
SysSound
TableSearch
TableViewSuite
TableViewUpdates
TaggedLocations
Teslameter
TheElements
ThreadedCoreData
ToolbarSearch
TopPaid
TopSongs
TouchCells
Touches
Trailers
TransWeb
UICatalog
URLCache
ViewTransitions
WeatherMap
WhichWayIsUp
WiTap
WorldCities
ZoomingPDFViewer
aurioTouch
avTouch
iAdSuite
iPhoneACFileConvertTest
iPhoneCoreDataRecipes
iPhoneExtAudioFileConvertTest
iPhoneMixerEQGraphTest
iPhoneMultichannelMixerTest
iPhoneUnitTests
oalTouch
EOF
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜