IOS源码封装成.bundle和.a文件时,使用单例作为出口的写法!任何封装都建议使用这种方法作为出口
2014-01-02 12:53
363 查看
头文件
以此作为模板,记录于此
#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
以此作为模板,记录于此
#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文件,以及加入xib的具体方法,翻遍网络,仅此一家完美翻译!! IOS7!!(3) 完美结局
- iOS使用自定义字体的方法(内置和任意下载ttf\otf\ttc字体文件)
- iOS 开发使用半透明模糊效果方法整理(欢迎分享和提建议)
- ios开发之使用bundle来管理资源文件
- iOS使用自定义字体的方法(内置和任意下载ttf\otf\ttc字体文件)
- 在 iOS 应用中使用 Lua 作为模块粘合剂的方法
- 使用getCurrentPosition方法实时获取当前Geolocation信息(附源码文件)--html5、JavaScript
- IOS基础学习笔记二:Bundle加载文件、XIB使用
- 黑马程序员_ADO.Net(配置文件的两种写法与使用方法,手动编写SqlHelper类)
- 使用Xcode为iOS应用项目创建PCH文件的方法及应用示例
- iOS 网络请求框架MKNetworkKit使用方法(欢迎提建议和分享遇到的问题)
- iOS中如何使用PCH文件、修改其相对路径的方法
- iOS 图片缓存框架SDWebImage使用方法(欢迎提建议和分享遇到的问题)
- ios开发版证书与企业证书相关文件申请安装及其使用方法
- IOS封装Framework,使用bundle管理资源
- iOS中如何使用PCH文件、修改其相对路径的方法
- iOS回顾笔记(03) -- 自定义View的封装和xib文件的使用详解
- eclipse无法生成class问文件的解决方法(使用TFS作为源代码管理器)
- iOS回顾笔记(03) -- 自定义View的封装和xib文件的使用详解
- Eclipse中查看没有源码的Class文件的方法——jadclipse插件使用