从苹果下载iphone示例代码

时间:2010-04-04 23:25:52

标签: iphone ios objective-c ipad

iphone sdk文档包含示例代码的链接,但您必须从Web上单独下载它们。有没有可以从苹果一次下载的捆绑包?

例如,在switchonthecode上阅读first iphone tutorial,我遇到的第一个新单词是UIApplication。网上有5个样本......

4 个答案:

答案 0 :(得分:4)

我也是初学者,发现很烦人他们没有“所有例子”拉链。它们也不容易自动将它们拉下来,因为它们使用javascript来填充示例列表。

幸运的是,我能够使用Chrome检查示例页面,并为我提供有效的“最终结果”HTML并使用它来创建此脚本,该脚本将下载并解压缩所有示例。

希望我们作为一个社区可以保持这个列表,但截至今天它确实包含了所有的例子。

<强> 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

在相关的说明中,我发现ack是比搜索/ grep

更好的搜索示例的方法

希望这能帮助他人,就像它帮助我一样。

答案 1 :(得分:3)

http://www.jerrybeers.com/index.php/2011/06/18/copying-xcode-samples/显示如何从您计算机上的现有xcode安装中获取所有样本。非常有用!

答案 2 :(得分:1)

感谢David Blevins上面的原始发布。我手动寻找任何第一个添加的和grep'd大卫的脚本添加新的东西,希望保持脚本是最新的:

    #!/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

答案 3 :(得分:1)

对于OSX上的那些人(并且没有wget /不想为此安装它)。此外,它看起来已从http转移到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