小编sch*_*udu的帖子

强标识符是@property语句的默认标识符吗?

我正在学习Objective-C和Cocoa Framework(通过Aaron Hillgass的书),并试图弄清楚为什么以下行包含"强"标识符.

@property (strong) NSManagedObjectContext *managedObjectContext;
Run Code Online (Sandbox Code Playgroud)

据我了解,强是默认的,为什么我需要明确声明它?

cocoa objective-c

18
推荐指数
1
解决办法
9123
查看次数

Rails验证... multiple:on options?

是否可以:onvalidates验证选项提供 多个条目?

类似于以下内容:

class Library < ActiveRecord::Base

  validates :presence => true, :on => [:create, :update, :some_other_action]

end
Run Code Online (Sandbox Code Playgroud)

基本上我想在控制器中调用多个动作时运行一个特定的验证.例如,我想验证有关create操作,update操作以及可能的其他操作的一些用户信息.

虽然我不希望验证在所有方法上运行.

此外,如果有一个更简单的方法,这也将是伟大的!

提前致谢!

validation ruby-on-rails

10
推荐指数
2
解决办法
4253
查看次数

帮助书中的锚点无法正常工作

我已经仔细检查了一切,并希望有人能找到一个我没见过的愚蠢的错误.

我正在尝试为我的应用程序构建Apple帮助部分,它正确地转到登录页面,但没有任何锚点工作.调用登录页面并调用位于目录中index.html的另一个页面. test.htmlpgs

在index.html我有:

<a href="help:anchor=support bookID=com.company.app_name.help">Link to another page</a>
Run Code Online (Sandbox Code Playgroud)

在test.html我有:

<a name="support"></a>
Run Code Online (Sandbox Code Playgroud)

所以这是我为了到达现在的位置而遵循的步骤:

1)我构建了Apple文档指定的目录

AppName.help/
    Contents/
        Info.plist
        Resources/
            shrd/
            English.lproj/
                index.html
                search.helpindex
                pgs/
                    test.html
Run Code Online (Sandbox Code Playgroud)

2)我按照Apple文档中的规定构建了Help Info.plist.包含在我设置的Info.plist CFBundleIdentifiercom.company.app_name.help.

3)在我的应用程序Info.plist中,我将设置CFBundleHelpBookFolderAppName.help并设置CFBundleHelpBookNamecom.company.app_name.help

4)然后我将我内置的目录复制到Xcode中,同时确保为任何添加的文件夹选择了Create Folder References选项.

5)然后我使用Help Indexer索引目录AppName.help.确保我选择了在所有文件中索引锚信息的选项.然后将.helpindex文件复制到应该是的English.lproj文件夹中.

而已.如果我在index.html文件中放置以下链接它可以正常工作,我注意到有关我的应用程序的一些事情.

<a href="pgs/test.html">Click this link</a>                 
Run Code Online (Sandbox Code Playgroud)

这也是我的index.html代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head> …
Run Code Online (Sandbox Code Playgroud)

cocoa xcode4 apple-help help-viewer

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

使用轮胎宝石为特定领域设置Elasticsearch分析器

我有一个Resource对象,它包含以下字段:title,descriptionbody.

使用轮胎宝石我想使用标准分析仪来标题描述,但对于身体领域我想使用雪球分析仪.

所以在我的resource.rb文件中,我有以下代码:

mapping do
  indexes :title, type: 'string', :index => :not_analyzed, :store => true
  indexes :description, type: 'string'
  indexes :body, type: 'string', :analyzer => 'snowball'
end

def self.search(params)
  search_query = params[:query]

  tire.search(page: params[:page], per_page: 15) do |s|
    s.query { string params[:query], default_operator: "AND"} if params[:query].present?
    # do i need another line here specifically for description?
    #s.query { string "body:#{params[:query]}", analyzer: 'snowball'} if params[:query].present?
  end
end …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails elasticsearch tire

2
推荐指数
1
解决办法
2331
查看次数