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 ...
随机推荐
- firefox hack
@-moz-document url-prefix(){ css选择器 { css样式设置 } }
- FileUpload上传与下载
后台代码: public string connstr = "server=128.1.3.113;database=test;uid=sa;pwd=pass"; protecte ...
- struts2拦截器与过滤器
转载:http://www.cnblogs.com/JohnLiang/archive/2011/12/15/2288376.html 过滤器,是在java web中,你传入的request,resp ...
- 25个有用和方便的 WordPress 速查手册
如果你是一个 WordPress 编码器或开发人员,下载一些方便的 WordPress 备忘单寻找你的工作然后你在正确的地方.我们已经列出了25个有用的和方便的 WordPress 速查手册.Word ...
- 搭建SSH框架所需Jar包及其解释
SSH2 ----struts2.1.8---- struts2-core-2.1.8.1.jar struts2核心包 struts2-json-plugin-2.1.8.1.jar struts2 ...
- VBA读取可选择文件夹下可选择txt文件内容
Sub OneTxt() '打开一个txt文件 Dim Filename As Variant, extLine&, mArr() As String Dim i%, j% ChDir Thi ...
- 升级Xcode6.4插件失效解决办法
发现安装的插件无效 后各种尝试后终于解决 1.先找到之前装的插件文件夹 前往文件夹:~/Library/Application Support/Developer/Shared/Xcode/Plug- ...
- Oracle中varchar,varchar2,nvarchar,nvarchar2的区别
--varchar,varchar2 联系:1.varchar/varchar2用于存储可变长度的字符串比如varchar(20),存入字符串'abc',则数据库中该字段只占3个字节,而不是20个字节 ...
- web安全测试-AppScan
安全测试应该是测试中非常重要的一部分,但他常常最容易被忽视掉. 尽管国内经常出现各种安全事件,但没有真正的引起人们的注意.不管是开发还是测试都不太关注产品的安全.当然,这也不能怪我们苦B的“民工兄弟” ...
- C++指针详解
指针的概念 指针是一个特殊的变量,它里面存储的数值被解释成为内存里的一个地址.要搞清一个指针需要搞清指针的四方面的内容:指针的类型,指针所指向的类型,指针的值或者叫指针所指向的内存区,还有指针本身所占 ...