小编khe*_*aud的帖子

如何将NSString路径转换为CFURLRef(对于iOS 3.1)?

我在UIScrollView中显示PDF.为此,我使用:

myDocumentRef = CGPDFDocumentCreateWithURL((CFURLRef)[[NSBundle mainBundle] URLForResource:@"salonMap" withExtension:@"pdf"]);
Run Code Online (Sandbox Code Playgroud)

现在,我尝试使其适用于IOS 3.1(NSBundle URLForResource:3.1中不存在withExtension)

我将代码转换为:

NSString *fullPath =  [[NSBundle mainBundle] pathForResource:@"salonMap" ofType:@"pdf"];
NSLog(@"%@", fullPath);
CFStringRef fullPathEscaped = CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)fullPath, NULL, NULL,kCFStringEncodingUTF8);
CFURLRef urlRef = CFURLCreateWithString(NULL, fullPathEscaped, NULL);
myDocumentRef = CGPDFDocumentCreateWithURL(urlRef);
Run Code Online (Sandbox Code Playgroud)

但它导致了一个

<Error>: CFURLCreateDataAndPropertiesFromResource: failed with error code -15
Run Code Online (Sandbox Code Playgroud)

我确切地说NSLog记录了

/var/mobile/Applications/1CF69390-85C7-45DA-8981-A279464E3249/myapp.app/salonMap.pdf"
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

iphone nsurl cfstring nsbundle ios

7
推荐指数
1
解决办法
6474
查看次数

将unix时间戳更改为其他时区

我从Python程序中的Web服务检索unix时间戳.此时间戳位于美国时区.为了将其插入到MySQL数据库中与其他对象(位于法国),我想将此时间戳转换为法国时区.

我可以用数学函数来做,但是有夏令时的问题.我更喜欢使用Python时间和日期特定的功能来处理这些概念.

你有提示吗,我迷失在Python文档中?

python timezone datetime date

7
推荐指数
2
解决办法
6284
查看次数

图API/FQL如何从用户删除我自己的应用程序?

当我接受我的申请时,我从用户那里获得了offline_access.现在,在我的网站中,用户可以删除我对他的Facebook帐户的访问权限.有没有办法,告诉Facebook从这个用户删除我的应用程序?

谢谢你的帮助

facebook facebook-graph-api

7
推荐指数
1
解决办法
3440
查看次数

不可能用特殊字符git rm

我在我的git存储库中添加了我想要删除的文件.我用它删除了它rm XXX.现在,git status告诉我:

Changed but not updated:
    deleted:    "Sche\314\201ma application + interface.graffle"
Run Code Online (Sandbox Code Playgroud)

不管我怎么样git rm,我还有一个:

fatal: pathspec 'Schêma application + interface.graffle' did not match any files
Run Code Online (Sandbox Code Playgroud)

我试图逃跑的空格用\,为了躲避\\\,逃跑"\".无论我尝试什么,都失败了.

你有提示吗?

git encoding git-rm

7
推荐指数
1
解决办法
2111
查看次数

以编程方式设置UITabBarItem标题?

我的应用程序基于标签栏架构.为了拥有一个简单的国际化机制,我不在XIB文件中写任何字符串.viewdidload允许以编程方式更改视图中的字符串.

当我的应用程序启动时,我可以看到4个选项卡.但事实上只有第一个加载其视图控制器.其他人等待用户点击加载.可以使用[self setTitle:@"Mouhahaha"]更改标签标题; 在viewDidLoad中加载了视图控制器.

如果我想保持我的国际化机制,我不会在我的XIB中设置tabbar项的名称.但是,在开始时所有选项卡的视图控制器都没有加载,我有一些标签的空白标题.仅当用户单击选项卡时才设置右侧标题.

我正在寻找一种方法来为每个tabbaritem设置这个标题programaticaly.你有提示吗?

非常感谢.

kheraud

uitabbarcontroller viewdidload uitabbaritem uitabbar ios

6
推荐指数
1
解决办法
8107
查看次数

如何在许多文件中导入常量

我有一个包含许多模块的包.每个模块使用我在每个文件中独立定义的常量.但是,所有这些常量必须相互一致.所以我尝试在一个文件中定义它们并将其导入每个文件中.当我运行它时,我找不到常量的常量错误.

他们是一个干净的方式让一个文件由许多其他人导入并包含常量?

谢谢你的帮助

python import package

5
推荐指数
1
解决办法
8704
查看次数

HQL/JPQL - 在FROM上嵌套选择

我尝试将我的SQL查询转换为HQL或JPQL(我希望受益于对象映射).

我的SQL请求是:

SELECT * 
FROM (SELECT bde, MAX(creation_date) 
      FROM push_campaign GROUP BY bde) temp, 
push_campaign pc where pc.bde = temp.bde and pc.creation_date = temp.creation_date;
Run Code Online (Sandbox Code Playgroud)

我尝试(不成功)在JPQL中转换它:

select pc 
from (select bde, max(creationDate) 
      from PushCampaign group by bde) temp, 
PushCampaign pc 
where pc.bde = temp.bde and pc.creationDate = temp.creationDate
Run Code Online (Sandbox Code Playgroud)

但我得到了提升:

IllegalArgumentException occured :
Run Code Online (Sandbox Code Playgroud)

org.hibernate.hql.ast.QuerySyntaxException:意外令牌:(第1行,第16列[选择pc from(select id,max(creationDate)from models.PushCampaign group by bde)temp,models.PushCampaign pc where pc.id = temp.id]

我读的嵌套选择只能在select或where子句中.

您是否有解决方案来保持对象映射的请求和好处?

sql nhibernate hql jpql

5
推荐指数
1
解决办法
1万
查看次数

播放2.0模型的最佳实践

我正在寻找关于模型的最佳实践以及使用play 2.0在数据库中持久保存对象的方法.我已经使用scala研究了Play和类型安全样本for play 2.0.

我的理解是:

  • 该模型在案例类中定义
  • 所有insert/update/delete/select都在此case类的伴随对象中定义

因此,如果我需要更新我的Car对象以定义新的所有者,我将不得不这样做:

val updatedCar = myCar.copy(owner=newOwner)
Car.update(updatedCar)
// or
Car.updateOwner(myCar.id.get, newOwner)
Run Code Online (Sandbox Code Playgroud)

我想知道为什么更新或删除语句不在case类本身:

case class Car(id: Pk[Long] = NotAssigned, owner: String) {
    def updateOwner(newOwner: String) {
        DB.withConnection { implicit connection =>
            SQL(
                """
                update car
                set owner = {newOwner}
                where id = {id}
                """
            ).on(
                'id -> id,
                'newOwner -> newOwner
            ).executeUpdate()
        }
        copy(owner = newOwner)
    }
}
Run Code Online (Sandbox Code Playgroud)

这样做可以做到:

val updatedCar = myCar.updateOwner(newOwner)
Run Code Online (Sandbox Code Playgroud)

这就是我以前使用Java和JPA对Play 1.X所做的.也许原因很明显,并且由于我对Scala的了解不多.

scala model playframework playframework-2.0

5
推荐指数
1
解决办法
1855
查看次数

Logback配置在一行上有例外?

我的日志被提取,管道并合并到elasticsearch中.多线事件很难跟踪和诊断.

而不是使用收集器和正则表达式来组合单个记录中的异常行,是否有一种方法可以使用logback配置Exception堆栈跟踪放在一行上?

java logging logback slf4j

5
推荐指数
1
解决办法
2386
查看次数

内存问题/ overrelease with navigationcontroller和包含子CALayer的视图

我在周末期间未能解决这个问题...我认为对Objective-C内存管理有很好的了解,但是这个很难解决.

总结一下上下文:我有一个吸引人的UIViewController,我在我的navigationcontroller中推送.这个UIViewController包含一个UIScrollView(在IB中创建).在UIViewController viewDidLoad()函数中,我添加了一个背景PDF(在UIview层的CATiledLayer子层中).

问题是,当我从导航控制器弹出UIViewController时,应用程序崩溃了.

使用Zombies工具和NSZombieLevel表明这是因为UIViewController被过度释放.

这是UIViewController:

@interface PlanViewController : UIViewController <UIScrollViewDelegate> {
    UIScrollView *panelScrollView;
    UIView *myContentView;
    CGPDFDocumentRef myDocumentRef;
    CGPDFPageRef myPageRef;
}

@property (nonatomic, retain) IBOutlet UIScrollView *panelScrollView;
@property (nonatomic, retain) UIView *myContentView;

@end

@implementation PlanViewController
@synthesize panelScrollView;
@synthesize myContentView;

- (void)viewDidLoad {
    [self setTitle:@"Plan"];

    myDocumentRef = CGPDFDocumentCreateWithURL((CFURLRef)[[NSBundle mainBundle] URLForResource:@"salonMap" withExtension:@"pdf"]);
    myPageRef = CGPDFDocumentGetPage(myDocumentRef, 1);
    CGRect pageRect = CGRectIntegral(CGPDFPageGetBoxRect(myPageRef, kCGPDFCropBox));

    CATiledLayer *tiledLayer = [[CATiledLayer alloc] init];
    [tiledLayer setDelegate:self];
    [tiledLayer setTileSize:CGSizeMake(1024.0, 1024.0)];
    [tiledLayer setLevelsOfDetail:4];
    [tiledLayer setLevelsOfDetailBias:8];
    [tiledLayer setFrame:pageRect]; …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch memory-management release-management uinavigationcontroller

4
推荐指数
1
解决办法
1178
查看次数