【实例简介】

【实例截图】

【核心代码】

// UIAlertView AFNetworking.m

// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)

//

// Permission is hereby granted, free of charge, to any person obtaining a copy

// of this software and associated documentation files (the "Software"), to deal

// in the Software without restriction, including without limitation the rights

// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

// copies of the Software, and to permit persons to whom the Software is

// furnished to do so, subject to the following conditions:

//

// The above copyright notice and this permission notice shall be included in

// all copies or substantial portions of the Software.

//

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN

// THE SOFTWARE.

#import "UIAlertView AFNetworking.h"

#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)

#import "AFURLConnectionOperation.h"

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000

#import "AFURLSessionManager.h"

#endif

static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __autoreleasing *title, NSString * __autoreleasing *message) {

if (error.localizedDescription && (error.localizedRecoverySuggestion || error.localizedFailureReason)) {

*title = error.localizedDescription;

if (error.localizedRecoverySuggestion) {

*message = error.localizedRecoverySuggestion;

} else {

*message = error.localizedFailureReason;

}

} else if (error.localizedDescription) {

*title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description");

*message = error.localizedDescription;

} else {

*title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description");

*message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%@ Error: %ld", @"AFNetworking", @"Fallback Error Failure Reason Format"), error.domain, (long)error.code];

}

}

@implementation UIAlertView (AFNetworking)

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000

(void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task

delegate:(id)delegate

{

[self showAlertViewForTaskWithErrorOnCompletion:task delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil];

}

(void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task

delegate:(id)delegate

cancelButtonTitle:(NSString *)cancelButtonTitle

otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION

{

NSMutableArray *mutableOtherTitles = [NSMutableArray array];

va_list otherButtonTitleList;

va_start(otherButtonTitleList, otherButtonTitles);

{

for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) {

[mutableOtherTitles addObject:otherButtonTitle];

}

}

va_end(otherButtonTitleList);

__block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingTaskDidCompleteNotification object:task queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {

NSError *error = notification.userInfo[AFNetworkingTaskDidCompleteErrorKey];

if (error) {

NSString *title, *message;

AFGetAlertViewTitleAndMessageFromError(error, &title, &message);

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil];

for (NSString *otherButtonTitle in mutableOtherTitles) {

[alertView addButtonWithTitle:otherButtonTitle];

}

[alertView setTitle:title];

[alertView setMessage:message];

[alertView show];

}

[[NSNotificationCenter defaultCenter] removeObserver:observer];

}];

}

#endif

#pragma mark -

(void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation

delegate:(id)delegate

{

[self showAlertViewForRequestOperationWithErrorOnCompletion:operation delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil];

}

(void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation

delegate:(id)delegate

cancelButtonTitle:(NSString *)cancelButtonTitle

otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION

{

NSMutableArray *mutableOtherTitles = [NSMutableArray array];

va_list otherButtonTitleList;

va_start(otherButtonTitleList, otherButtonTitles);

{

for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) {

[mutableOtherTitles addObject:otherButtonTitle];

}

}

va_end(otherButtonTitleList);

__block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification object:operation queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {

if (notification.object && [notification.object isKindOfClass:[AFURLConnectionOperation class]]) {

NSError *error = [(AFURLConnectionOperation *)notification.object error];

if (error) {

NSString *title, *message;

AFGetAlertViewTitleAndMessageFromError(error, &title, &message);

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil];

for (NSString *otherButtonTitle in mutableOtherTitles) {

[alertView addButtonWithTitle:otherButtonTitle];

}

[alertView setTitle:title];

[alertView setMessage:message];

[alertView show];

}

}

[[NSNotificationCenter defaultCenter] removeObserver:observer];

}];

}

@end

#endif

百思不得姐php源码,百思不得姐源代码(xcode)相关推荐

  1. mfc使用cef源代码实现_如何获得微信小游戏跳一跳源码以及源代码组合包括哪些...

    很多小游戏都是由源代码编写而成的,那大家知道源代码组合包括哪些吗?手机游戏源代码怎么使用的呢?还有,如何获得微信小游戏跳一跳源码?下面就由奇瑰网小编带大家来了解一下相关的内容吧. 源代码组合包括哪些 ...

  2. 如何拷贝工程_如何获得微信小游戏跳一跳源码以及源代码组合包括哪些

    很多小游戏都是由源代码编写而成的,那大家知道源代码组合包括哪些吗?手机游戏源代码怎么使用的呢?还有,如何获得微信小游戏跳一跳源码?下面就由奇瑰网小编带大家来了解一下相关的内容吧. 源代码组合包括哪些 ...

  3. c语言小游戏跳一跳代码及注释,如何获得微信小游戏跳一跳源码以及源代码组合包括哪些...

    原标题:如何获得微信小游戏跳一跳源码以及源代码组合包括哪些 很多小游戏都是由源代码编写而成的,那大家知道源代码组合包括哪些吗?手机游戏源代码怎么使用的呢?还有,如何获得微信小游戏跳一跳源码?下面就由奇 ...

  4. C、C++、VC、MFC网页自动注册、登陆、发帖、留言 QQ注册、QQ申请器源码、源代码

    查看文章   [转]C.C++.VC.MFC网页自动注册.登陆.发帖.留言 QQ注册.QQ申请器源码.源代码 2012-01-11 10:58 转载自 qq316293804 最终编辑 qq31629 ...

  5. C#工业触摸屏上位机源码 纯源代码 替代传统plc搭载的触摸屏

    C#工业触摸屏上位机源码 0, 纯源代码. 1, 替代传统plc搭载的触摸屏. 2, 工控屏幕一体机直接和plc通信. 3, 功能强大,多级页签. 4, 可以自由设定串口或以太网通信. 5, 主页. ...

  6. 新闻管理系统源码java_小虫新闻管理系统 .rar - WEB源码|JSP源码/Java|源代码 - 源码中国...

    压缩包 : 小虫新闻管理系统 .rar 列表 downcode.com downcode.com\xwgl downcode.com\xwgl\classes downcode.com\xwgl\cl ...

  7. 拍卖系统源码 java,基于B2C的网上拍卖系统_秒杀与竞价 - WEB源码|JSP源码/Java|源代码 - 源码中国...

    文件名大小更新时间 a014基于B2C的网上拍卖系统_秒杀与竞价02019-08-15 a014基于B2C的网上拍卖系统_秒杀与竞价\截图02020-05-29 a014基于B2C的网上拍卖系统_秒杀 ...

  8. 教务管理系统java源代码,教务管理系统 - WEB源码|JSP源码/Java|源代码 - 源码中国...

    教务管理系统\E-R图.doc 教务管理系统\UML图.doc 教务管理系统\代码注释\login\11.jpg 教务管理系统\代码注释\login\LoginFrame.java 教务管理系统\代码 ...

  9. estore java_estore2 - WEB源码|JSP源码/Java|源代码 - 源码中国

    estore-黑江伟\安装说明\oracle.txt .............\源码\estore_struts\.classpath .............\....\............ ...

  10. 【190515】网页爬虫VC++源码下载源代码

    源码下载简介 网页爬虫VC++源码下载,网页爬虫,可实现速度很快的信息爬取,为搜索引擎提供资源. 源码下载地址:点击下载 备用下载地址:点击下载

最新文章

  1. lighttpd 负载均衡-反向代理+cache浅谈
  2. 【转载】DotNet 资源大全中文版
  3. 你知道数据中心宕机的真正成本吗?
  4. 交叉工具链的搭建方法(测试成功)
  5. mac mongodb可视化工具_MongoDB从立地到成佛(介绍、安装、增删改查)
  6. 谷歌Chrome浏览器欲推门户网站聚合 正测试新“探索”页面
  7. 吐槽安卓系统体验差用户 这次啪啪啪打脸了
  8. pom.xml 配置maven私服
  9. java151和152_编写高质量代码:改善Java的151个建议(性能和效率)132-133
  10. @AutoConfigureAfter注解
  11. 多线程下载王者荣耀高清壁纸
  12. (转)鲶鱼理论、鲶鱼效应
  13. 一下科技何一:移动视频风口,内容创业者如何飞升?
  14. hadoop培训感想
  15. 吉大网络教育护理学专升本病例分析
  16. android 多渠道打包不同的包名、应用名、应用图标
  17. [渝粤教育] 天水师范学院 陶质文物保护修复 参考 资料
  18. 如何使用计算机建模,计算机模拟在数学建模中的应用
  19. 字符型数据与数值型数据之间的转换
  20. 10.5国庆作业(IIC实验)

热门文章

  1. android 实现果冻动画效果,HTML5/Canvas粘滑的果冻动画特效
  2. mysql语句大全文档_mysql语句大全免费
  3. Windows11 21H2 专业版 64位 v2022 【全新装机】
  4. php过气了吗,她怎么就过气了?
  5. Hexo+Github轻松搭建个人博客
  6. 第22批符合道路运输车辆卫星定位系统标准 及规范的车载终端
  7. HBuilder升级失败,/HBuilder/plugins 被另—个程序占用,请退出占用程序或者重启计算机后重试
  8. python竖线_python 读取竖线分隔符的文本方法
  9. 【机器学习】使用 IQR、Z 分数、LOF 和 DBSCAN 检测异常值
  10. 怎么做一个有价值的人