IOS源码封装成.bundle和.a文件时,使用单例作为出口的写法!任何封装都建议使用这种方法作为出口
头文件
以此作为模板,记录于此
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
//this can write delegate directly,but out of the class ,can't see the class,so we add a @class
@class HWeatherManager;
@protocol HWeatherManagerDelegate <NSObject>
//use the delegate pass by value
-(void)test:(NSString *)str;
@end
@interface HWeatherManager : NSObject
@property (nonatomic,strong)UIViewController <HWeatherManagerDelegate> * delegate;
+(HWeatherManager *)defaultManager;
-(void)start;
-(void)endWeather;
@end
实现部分
#import "HWeatherManager.h"
#import "HWeatherViewController.h"
@implementation HWeatherManager
+(HWeatherManager *)defaultManager
{
static HWeatherManager *manager=Nil;
@synchronized(self)
{
if (manager==Nil) {
manager=[[HWeatherManager alloc]init];
[HWeatherViewController class];
}
}
return manager;
}
-(void)start
{
// [self.delegate test:@"hello"];
NSBundle *bundle=[NSBundle bundleWithURL:[[NSBundle mainBundle]URLForResource:@"HWeatherDataLibResources" withExtension:@"bundle"]];
UIStoryboard *storyboard=[UIStoryboard storyboardWithName:@"WeatherStoryboard" bundle:bundle];
// NSLog(@"--%@",navigation);
[self.delegate presentViewController:[storyboard instantiateInitialViewController] animated:YES completion:^{
}];
}
-(void)endWeather
{
UIStoryboard *storyboard=[UIStoryboard storyboardWithName:@"Main" bundle:Nil];
[self.delegate presentViewController:[storyboard instantiateViewControllerWithIdentifier:@"endWeather"] animated:YES completion:^{
}];
}
@end
IOS源码封装成.bundle和.a文件时,使用单例作为出口的写法!任何封装都建议使用这种方法作为出口的更多相关文章
- IOS源码封装成.bundle和.a文件,以及加入xib的具体方法,翻遍网络,仅此一家完美翻译!! IOS7!!(3) 完美结局
以上翻译有误解之处,现在简单做法如下: 经过深入研究,才感觉明白了内部机制,现在简单介绍于下,主要步骤:xcode5 创建库项目,删掉测试文件和默认创建的类,添加viewController类带xib ...
- ios源码-ios游戏源码-ios源码下载
游戏源码 一款休闲类的音乐小游戏源码 该源码实现了一款休闲类的音乐小游戏源码,该游戏的源码很简单,而且游戏的玩法也很容易学会,只要我们点击视图中的grid,就可以 人气:2943运行环境:/Xco ...
- EarthWarrior3D游戏ios源码
这是一款不错的ios源码源码,EarthWarrior3D游戏源码, 并且游戏源代码支持多平台. 适用于cocos v2.1.0.0版本 源码下载:http://code.662p.com/view/ ...
- 非常不错的点餐系统应用ios源码完整版
该源码是一款非常不错的点餐系统应用,应用源码齐全,运行起来非常不错,基本实现了点餐的一些常用的功能,而且界面设计地也很不错,是一个不错的ios应用学习的例子,喜欢的朋友可以下载学习看看,更多ios源码 ...
- 自动计算尺寸列表功能案例ios源码
源码HTKDynamicResizingCell,HTKDynamicResizingCell提供自动计算尺寸的TableViewCell/CollectionViewCel,只要设置了合适AutoL ...
- [源码解析] PyTorch 分布式之弹性训练(2)---启动&单节点流程
[源码解析] PyTorch 分布式之弹性训练(2)---启动&单节点流程 目录 [源码解析] PyTorch 分布式之弹性训练(2)---启动&单节点流程 0x00 摘要 0x01 ...
- iOS页面间传值的方式(NSUserDefault/Delegate/NSNotification/Block/单例)
iOS页面间传值的方式(NSUserDefault/Delegate/NSNotification/Block/单例) 实现了以下iOS页面间传值:1.委托delegate方式:2.通知notific ...
- 【转】iOS页面间传值的方式(Delegate/NSNotification/Block/NSUserDefault/单例)-- 不错
原文网址:http://www.cnblogs.com/JuneWang/p/3850859.html iOS页面间传值的方式(NSUserDefault/Delegate/NSNotificatio ...
- iOS页面间传值的方式 (Delegate/NSNotification/Block/NSUserDefault/单例)
iOS页面间传值的方式(Delegate/NSNotification/Block/NSUserDefault/单例) iOS页面间传值的方式(NSUserDefault/Delegate/NSN ...
随机推荐
- script "text/template"
<script type="text/template" id="orgItem"> <div class="{orgClass}& ...
- 玩转linux文件(重点)
一.几个主要的操作 mkdir—创建目录 cp—复制文件和目录 mv——移动/重命名文件和目录 rm——删除文件和目录 ln——创建硬链接和软链接 二.几个考点: 通配符 硬链接和软链接(符号链接) ...
- postgres 正则表达式
PostgreSQL正则表达式 基础: Operator Description Example ~ Matches regular expression, case sensitive 'thoma ...
- C#多态问题
为什么对这个感觉趣呢.因为以前写过两篇关于这个多态和重载混合起来很乱的调用情况分析,自从哪以后,我自认为随便乱写一些继承多态的代码都应该难不到我.但是今天看到一段代码有一个地方计算错误了,所以有必要写 ...
- PHP FTP操作类( 上传、拷贝、移动、删除文件/创建目录 )
/** * 作用:FTP操作类( 拷贝.移动.删除文件/创建目录 ) * 时间:2006/5/9 * 作者:欣然随风 * QQ:276624915 */ class class_ftp { publi ...
- 我们无法找到服务器加载工作簿的数据模型"的 SharePoint 网站,当您刷新 Excel 2013 工作簿中的数据透视表时出错
假定您使用 Analysis Services 源在 Microsoft Excel 2013 中创建数据透视表.将 Excel 工作簿上载到 Microsoft SharePoint 网站中.当您尝 ...
- office 使用技巧
Excel: 非打印区域显示成灰色:视图--分页预览 选定行的时侯,如何从某一行选定到末尾? 先点某一行,然后按住shift不松,再按END,再按下方向箭. 选定列也是这样,先按住某列,然后按SHIF ...
- Exif的Orientation信息说明
EXIF Orientation 参数让你随便照像但都可以看到正确方向的照片而无需手动旋转(前提要图片浏览器支持,Windows 自带的不支持) 这个参数在佳能.尼康相机照的照片是自带的,但我的奥林巴 ...
- Linux-如何查看登陆shell的类型
输入一个系统不认识的命令(如#ig)获得系统提示 aix/#ig ksh ig not found #echo $ (适用sh/ksh) aix/#echo $ ksh #echo $SHELL(用户 ...
- Rhel6-tomcat+nginx+memcached配置文档
理论基础: User - > web ->nginx ->tomcat1 ->*.jsp 80 8080 ↓ -> tomcat2 html ...