開始使用AFNetworking,使用AFNetworking

來源:互聯網
上載者:User

開始使用AFNetworking,使用AFNetworking

郝萌主傾心貢獻,尊重作者的勞動成果,請勿轉載。

如果文章對您有所協助,歡迎給作者捐贈,支援郝萌主,捐贈數額隨意,重在心意^_^ 

我要捐贈: 點擊捐贈

Cocos2d-X源碼下載:點我傳送


This is a guide to help developers get up to speed with AFNetworking. It is geared primarily towards anyone who is new to Mac or iOS development, or has not worked extensively with 3rd-party libraries before.

These step-by-step instructions are written for Xcode 5, using the iOS 7 SDK. If you are using a previous version of Xcode, you may want to update before starting.

Step 1: Download CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like AFNetworking in your projects.

CocoaPods is distributed as a ruby gem, and is installed by running the following commands in Terminal.app:

$ sudo gem install cocoapods$ pod setup

Depending on your Ruby installation, you may not have to run assudo to install the cocoapods gem.

Step 2: Create a Podfile

Project dependencies to be managed by CocoaPods are specified in a file calledPodfile. Create this file in the same directory as your Xcode project (.xcodeproj) file:

$ touch Podfile$ open -a Xcode Podfile

You just created the pod file and opened it using Xcode! Ready to add some content to the empty pod file?

Copy and paste the following lines into the TextEdit window:

source 'https://github.com/CocoaPods/Specs.git'platform :ios, '7.0'pod 'AFNetworking', '~> 2.5'

You shouldn’t use TextEdit to edit the pod file because TextEdit likes to replace standard quotes with more graphically appealing quotes. This can cause CocoaPods to get confused and display errors, so it’s best to just use Xcode or another programming text editor.

Step 3: Install Dependencies

Now you can install the dependencies in your project:

$ pod install

From now on, be sure to always open the generated Xcode workspace (.xcworkspace) instead of the project file when building your project:

$ open <YourProjectName>.xcworkspace
Step 4: Dive In!

At this point, everything's in place for you to start using AFNetworking. Just#import the headers for the classes you need and get to it!

郝萌主傾心貢獻,尊重作者的勞動成果,請勿轉載。

如果文章對您有所協助,歡迎給作者捐贈,支援郝萌主,捐贈數額隨意,重在心意^_^ 

我要捐贈: 點擊捐贈

Cocos2d-X源碼下載:點我傳送


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.