开始AFNetworking
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 as
sudo
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!
版权声明:本文博客原创文章,博客,未经同意,不得转载。
开始AFNetworking的更多相关文章
- 【原】AFNetworking源码阅读(六)
[原]AFNetworking源码阅读(六) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 这一篇的想讲的,一个就是分析一下AFSecurityPolicy文件,看看AF ...
- 【原】AFNetworking源码阅读(五)
[原]AFNetworking源码阅读(五) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇中提及到了Multipart Request的构建方法- [AFHTTP ...
- 【原】AFNetworking源码阅读(四)
[原]AFNetworking源码阅读(四) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇还遗留了很多问题,包括AFURLSessionManagerTaskDe ...
- 【原】AFNetworking源码阅读(三)
[原]AFNetworking源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇的话,主要是讲了如何通过构建一个request来生成一个data tas ...
- 【原】AFNetworking源码阅读(二)
[原]AFNetworking源码阅读(二) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇中我们在iOS Example代码中提到了AFHTTPSessionMa ...
- 【原】AFNetworking源码阅读(一)
[原]AFNetworking源码阅读(一) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 AFNetworking版本:3.0.4 由于我平常并没有经常使用AFNetw ...
- AFNetworking 3.0 源码解读 总结(干货)(下)
承接上一篇AFNetworking 3.0 源码解读 总结(干货)(上) 21.网络服务类型NSURLRequestNetworkServiceType 示例代码: typedef NS_ENUM(N ...
- AFNetworking 3.0 源码解读 总结(干货)(上)
养成记笔记的习惯,对于一个软件工程师来说,我觉得很重要.记得在知乎上看到过一个问题,说是人类最大的缺点是什么?我个人觉得记忆算是一个缺点.它就像时间一样,会自己消散. 前言 终于写完了 AFNetwo ...
- AFNetworking 3.0 源码解读(十一)之 UIButton/UIProgressView/UIWebView + AFNetworking
AFNetworking的源码解读马上就结束了,这一篇应该算是倒数第二篇,下一篇会是对AFNetworking中的技术点进行总结. 前言 上一篇我们总结了 UIActivityIndicatorVie ...
- AFNetworking 3.0 源码解读(十)之 UIActivityIndicatorView/UIRefreshControl/UIImageView + AFNetworking
我们应该看到过很多类似这样的例子:某个控件拥有加载网络图片的能力.但这究竟是怎么做到的呢?看完这篇文章就明白了. 前言 这篇我们会介绍 AFNetworking 中的3个UIKit中的分类.UIAct ...
随机推荐
- 如何抓取Thread Dump小结(转)
当系统性能出现问题时,需要从各个方面来查看网络环境.主机资源.查看最经变更的代码等.如果是想从代码层面解决问题,那么最有效的方法就是查看相关dump文件.如果是使用IBM JDK(我默认你是在aix环 ...
- php 父类调用子类方法和成员
在C和C++里,父类都不允许调用子类的方法,但在php里可以.下面是一个调用的例子: <?php abstract class Animal { protected $name; public ...
- Hdu 1175 连连看(DFS)
Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1175 因为题目只问能不能搜到,没问最少要几个弯才能搜到,所以我采取了DFS. 因为与Hdu ...
- C语言实现单链表的逆置
单链表的逆置是一个非常经典的问题,这里利用两个思想进行解决. 首先,我们需要看下原理图,其实两个思想都是一样的,都是使后一个的节点的 next 指针指向前一个节点,依次递推,直 ...
- PopupWindow的使用以及ArrayAdatper.notifyDataSetChanged()无效详解
Android的对话框有两种:PopupWindow和AlertDialog.它们的不同点在于: AlertDialog的位置固定,而PopupWindow的位置可以随意 AlertDialog是非阻 ...
- android通过服务实现消息推送
这里运用到的andorid知识模块主要有Notification和Service,和一个android-async-http-master开源框架 android项目中,有时会有这样一种需求:客户每隔 ...
- 如何改变c盘的访问权限
1.在文件夹或文件图标上面点击鼠标右键,再点击属性2.打开文件夹属性选项卡,按顺序单击:安全 > 高级 >所有者 > 编辑,选中Administrators用户组(或者你的用户所在的 ...
- linux eclipse中运行android AVD 错误
当使用android的AVD时提示以下错误: Starting emulator for AVD 'NexusOne' ERROR: 32-bit Linux Android emulator bin ...
- 一步一步重写 CodeIgniter 框架 (4) —— load_class 管理多个对象实例的思路
我们使用CodeIgniter 框架最主要是想利用其 MVC 特性,将模型.视图分开,并通过控制器进行统一控制.在尝试实现 MVC 模式之前,我们将实现其中一个对程序结构非常有用的技巧,就是 load ...
- 一步一步重写 CodeIgniter 框架 (3) —— 用面向对象重构代码
前面两篇文章为了重点突出 CodeIgniter 框架的原理,程序的结构很乱,有很多全局变量,在这一课中我们采用面向对象的方法对原先代码进行重构. 到目前为止,程序主要完成的就是 URL 分析,并根据 ...