V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  DingSoung  ›  全部回复第 44 页 / 共 59 页
回复总数  1180
1 ... 40  41  42  43  44  45  46  47  48  49 ... 59  
为什么没有林志玲的声音 鼓励的什么之类的
2015-09-30 11:53:01 +08:00
回复了 hydyy 创建的主题 职场话题 人生中第一次被辞退,真的是一个奇妙的感觉!
被辞好啊,有补偿金。
2015-09-30 11:46:02 +08:00
回复了 gdtv 创建的主题 程序员 中国 IT 人员平均年薪 27 万元 全球排名 13
把裤子都扯掉了,拖到脚后跟了
刚刚 Apple music movie 来了, 16G... 你自己想一下
2015-09-29 14:36:00 +08:00
回复了 DingSoung 创建的主题 Swift 同事把我用 Swift 写的工具删掉了,然后用 OC 重写了一遍...
@dorentus 发现了 谢谢
2015-09-29 13:31:19 +08:00
回复了 DingSoung 创建的主题 Swift 同事把我用 Swift 写的工具删掉了,然后用 OC 重写了一遍...
V2EX 不是支持 MarkDown 么
2015-09-29 13:30:26 +08:00
回复了 DingSoung 创建的主题 Swift 同事把我用 Swift 写的工具删掉了,然后用 OC 重写了一遍...
@gaitana 贴代码 有点长


```C
//
// QiniuManager.swift
// summer
//
// Created by Alex D. on 15/8/12.
//

import Qiniu
class QiniuManager {

static let instance = QiniuManager()
var upManager:QNUploadManager?
private init() {
upManager = QNUploadManager()
}

//MARK: 上传文件
func upload(token:String, data:NSData, key:String, process:((key:String, percent:Float)->Void)?, complete:((info:QNResponseInfo, key:String, resp:NSDictionary?)->Void)?, cancel:(()->Bool)?) {
let opt = QNUploadOption(mime: "text/plain", progressHandler: { (key, percent) -> Void in
print(key)
process?(key: key, percent: percent)
}, params: ["x:foo" : "fooval"], checkCrc: true) { () -> Bool in
//取消
if let block = cancel?() {
return block
}else {
return false
}
}
upManager?.putData(data, key: key, token: token, complete: { (info, key, resp) -> Void in
complete?(info: info, key: key, resp: resp)
}, option: opt)
}

//MARK: 断点续传
func upload(folder:String, token:String, data:NSData, key:String, process:((key:String, percent:Float)->Void)?, complete:((info:QNResponseInfo, key:String, resp:NSDictionary?)->Void)?, cancel:(()->Bool)?) {
do {
//写标记
self.upManager = try QNUploadManager(recorder: QNFileRecorder(folder: folder))
} catch {
self.upManager = QNUploadManager()
print("启动断点续传失败\(error),自动切换到连续上传")
}
self.upload(token, data: data, key: key, process: process, complete: { (info, key, resp) -> Void in
self.upManager = QNUploadManager()
complete?(info: info, key: key, resp: resp)
}) { () -> Bool in
cancel?()
if cancel?() == true {
self.upManager = QNUploadManager()
return true
}
return false
}
}
}
```

```C
//
// QiniuManager.m
// GiftBox
//
// Created by __ on 15/9/29.
//

#define kGetQiniuTokenURL xxxxx
#import "QiniuManager.h"
@interface QiniuManager()
@property (nonatomic, strong) QNUploadManager * manager;
@property (nonatomic, copy) NSString * token;
@property (nonatomic, assign) NSTimeInterval lastTime;
@end
@implementation QiniuManager
+ (QiniuManager *)sharedInstance {
static QiniuManager * manager;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
manager = [[QiniuManager alloc] init];
manager.manager = [[QNUploadManager alloc] init];
});
return manager;
}
- (void)uploadData:(NSData *)data
key:(NSString *)key
success:(void(^)(NSString * key))success
fail:(void (^)(NSError *))fail {
if (self.needRefreshToken) {
[self refreshTokenWithSuccess:^{
[self uploadData:data key:key success:success fail:fail];
} fail:^(NSError *error) {
if (fail) {
fail(error);
}
}];
} else {
[self.manager putData:data key:key token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
if (info.isOK && resp != nil) {
if (success) {
success(key);
}
} else {
if (fail) {
fail(info.error);
}
}
} option:nil];

}
}
- (void)refreshTokenWithSuccess:(void(^)())success fail:(void(^)(NSError * error))fail {
[NetworkManager addGetRequestWithURLString:[NSString stringWithFormat:kGetQiniuTokenURL, IS_DEBUG ? 4 : 2] tag:100 contentType:GBContentType success:^(NetworkManager *network, id responseObject) {
NSString * status = [responseObject objectForKey:@"status"];
if (status.integerValue == 0) {
NSString * qiniuToken = [responseObject objectForKey:@"token"];
self.token = qiniuToken;
self.lastTime = [NSDate date].timeIntervalSince1970;
if (success) {
success();
}
} else {
if (fail) {
fail([NSError errorWithDomain:[responseObject objectForKey:@"err_msg"] code:[[responseObject objectForKey:@"code"] integerValue] userInfo:nil]);
}
}
} fail:^(NetworkManager *network, NSError *error) {
if (fail) {
fail(error);
}
}];
}
//十分钟
- (BOOL)needRefreshToken {
NSTimeInterval nowTime = [NSDate date].timeIntervalSince1970;
return nowTime - self.lastTime > 60 * 10;
}
@end
```
2015-09-29 13:26:33 +08:00
回复了 DingSoung 创建的主题 Swift 同事把我用 Swift 写的工具删掉了,然后用 OC 重写了一遍...
@gaitana 搞不懂是他不习惯 Swift 还是嫌弃,不让就重复劳动了啊。囧
LZ 是没被 C 坑过
2015-09-29 12:20:49 +08:00
回复了 mhtt 创建的主题 问与答 是我的姿势不对?至今没察觉到 github 上 following 的意义
可以在动态里看同方向的朋友最近的活动,然后去跟着看一下学一下
2015-09-29 12:18:02 +08:00
回复了 cxe2v 创建的主题 分享发现 四川联通手机客户端 1G 流量半年包降到 30 块了
@revival83 也是自由组合套餐啊
2015-09-29 12:14:22 +08:00
回复了 cxe2v 创建的主题 分享发现 四川联通手机客户端 1G 流量半年包降到 30 块了
@revival83 北京联通有一个 30 的一个 80 的。。都是全国的 看不出区别。。

没看见啊 我手机 186 4G ,只有一个 80 的
2015-09-28 13:10:30 +08:00
回复了 v2xeuser 创建的主题 生活 急!买房是应该全款还是应该贷款?首付已经付了!
长见识了 看来我也要转变观念 选择贷款 把钱留着去投资
2015-09-24 10:31:31 +08:00
回复了 jun4rui 创建的主题 程序员 移动开发,原生还真不一定比 HTML5 强啊
我萌的商品详情 开始时 H5 + js, 太丑,卡,体验差。后来换原生, scrollview table 中间有部分是 web 流畅多了。
2015-09-22 13:37:17 +08:00
回复了 kidneyband 创建的主题 程序员 我不行了,改 iOS 项目的 xib,想跑路。
用 xib 有问题吗,约束不要用像素用比例啊,我适配的好好的。
我现在稍微复杂一点的 view 基本都用 xib. 动态的,带效果的采用代码写
2015-09-21 13:05:21 +08:00
回复了 1ychee 创建的主题 macOS 《曾经估值 10 亿美元,要做 100 年的印象笔记濒临》?
喜欢 google keep ,简单,方便,快捷, iOS 没有客户端,就用自带备忘录同步到 Gmail ,一样好用。
2015-09-20 15:47:40 +08:00
回复了 explon 创建的主题 分享发现 微信理财通红包攻略 - 23 个红包 (收益 130 元左右)
天天酷跑的没要 赚了 83.85
2015-09-18 15:53:03 +08:00
回复了 lisonfan 创建的主题 程序员 垃圾网易,开发 iOS 还用黑苹果? Xcode 还在百度上去下载?
扯毛线文化,大公司,真要舍得钱,要是为了开发好,就给全局自由网络访问,给不卡的开发机,给全套不同版本型号测试机。

那么多人用了百度那里流出来的 Xcode ,出了这么大的事,程序员说 ##“怪我咯?”

现在好多猿自备 VPN ,拿自己手机当开发机,猿想啊。那些出问题了的 app 的公司好好想想吧。
1 ... 40  41  42  43  44  45  46  47  48  49 ... 59  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   949 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 40ms · UTC 21:23 · PVG 05:23 · LAX 14:23 · JFK 17:23
Developed with CodeLauncher
♥ Do have faith in what you're doing.