我正在尝试子类NSNotification
.
Apple的文档NSNotification
陈述如下:
NSNotification
是一个没有实例变量的类集群.因此,你必须继承NSNotification
和覆盖原始的方法name
,object
和userInfo
.您可以选择任何您喜欢的指定初始值设定项,但请确保您的初始化程序不会调用 (via )NSNotification
的实现. 并不意味着直接实例化,它的 方法引发了异常.init
[super init]
NSNotification
init
但这对我来说并不清楚.我应该创建这样的初始化器吗?
-(id)initWithObject:(id)object
{
return self;
}
Run Code Online (Sandbox Code Playgroud) 当我的应用程序在iPhone上运行时,我发生间歇性崩溃.所有崩溃都是相同的,并以某种方式涉及MKMapView Overlays(MKCircleViews).
从典型的iPhone 4s崩溃报告:
报告标题:
Hardware Model: iPhone4,1
Process: EL-GPS-01 [1021]
Path: /var/mobile/Applications/61288E15-74B5-45B9-99A9-E0B58C767816/EL-GPS-01.app/EL-GPS-01
Identifier: EL-GPS-01
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2011-11-22 15:59:41.065 +0000
OS Version: iPhone OS 5.0.1 (9A405)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000
Crashed Thread: 6
Run Code Online (Sandbox Code Playgroud)
崩溃的线程:
Thread 6 name: Dispatch queue: com.apple.root.default-priority
Thread 6 Crashed:
0 ??? 0000000000 0 + 0
1 CoreGraphics 0x319a87c2 0x31967000 + 268226
2 CoreGraphics 0x3199a9e6 0x31967000 + 211430
3 …
Run Code Online (Sandbox Code Playgroud) 我有一个自定义的UITableViewCell,它包含一个UIImageView和一个UILabel.单元格为320x104px,imageView占据整个区域,标签位于前面.只有8个细胞.
在ViewDidLoad中我预先创建所有需要的图像,并在字典中以正确的尺寸缓存它们.
当我滚动UITableView时,每次遇到新单元格时都会有明显的延迟.这对我来说毫无意义,因为它正在使用的图像已经被创建和缓存.所有我要求的单元格都是为了让UIImageView渲染图像.
我在xib中使用自定义单元格及其视图,并将我的UITableView配置为使用它:
[self.tableView registerNib:[UINib nibWithNibName:@"ActsCell"bundle:nil] forCellReuseIdentifier:myIdentifier];
细胞创建和配置:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString* reuseIdentifier = @"ActsCell";
ActsCell* cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
// Configure the cell...
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
- (void)configureCell:(ActsCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
Act* act = [self.acts objectAtIndex:indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.title.text = act.name;
cell.imageView.image = [self.imageCache objectForKey:act.uid];
}
Run Code Online (Sandbox Code Playgroud)
什么可能导致滞后?在完成所有时间密集型工作时,尝试执行任何异步操作似乎没有任何好处.
我的应用程序被拒绝了,所以我修改了它并准备重新提交它.我第一次提交它是1.0版本.我是否需要增加此重新提交的版本号?
似乎Sinatra的记录器仅在请求处理程序中可用(请参阅https://github.com/sinatra/sinatra#logging),但如果我想在其他地方使用记录器,例如在帮助程序方法或配置中,该怎么办?钩?Sinatra记录仪是否可通过其他方式获得?
我知道在使用BEM时,类名不应该直接反映HTML结构,但是如何命名包装元素呢?请忽略我的特定语法(靠近SUIT); 它仍然遵循BEM,只是采用不同的方式来区分元素.
例如:
<div class="?">
<footer class="PageFooter">
<h4 class="PageFooter-brand>…</h4>
<ul class="PageFooter-contactDetails">…</ul>
</footer>
<div>
Run Code Online (Sandbox Code Playgroud)
我现在将这个包装器在这个实例中分类为PageFooterWrapper
,但是这感觉很笨,因为包装器不是独立的 - 它纯粹存在于PageFooter
.显然,为所有内容添加前缀PageFooter-
是荒谬的,所以只留下将包装作为以下内容的一部分PageFooter
:PageFooter-wrapper
.这让我感到不安,因为有一个隐含的建议应用于此.
那么包装器的类应该是什么?
我有一个lerna repo,它包含以通常结构组织的多个包:
package.json
/packages
- alpha
package.json
- bravo
package.json
- charlie
package.json
Run Code Online (Sandbox Code Playgroud)
我需要转换所有包,我目前在每个包中都有以下脚本package.json
:
"build": "npm run build:noWatch -- --watch --verbose",
"build:noWatch": "babel src --out-dir lib --root-mode upward --ignore '**/*.test.js','**/__tests__'",
"prebuild": "rimraf lib/*"
Run Code Online (Sandbox Code Playgroud)
我目前使用以下命令运行构建:
lerna run build --stream --parallel
Run Code Online (Sandbox Code Playgroud)
但是,我不想为每个包复制这些脚本.我想在一个地方定义脚本,但是在所有包中使用它们.我目前在我的root包中有linting脚本和测试脚本,因为它们有效地遍历整个monorepo寻找测试或文件到lint.将构建脚本移动到那里以及将它们限定在各个包中并不是有意义的.我喜欢这样的事实:当我使用时,每个包都会得到不同的颜色输出lerna run
.
一个令人不满意的解决方案是在monorepo的根目录中创建一些shell脚本,并从包的package.json
文件中调用它们:
在root/packages/example/package.json
:
"scripts": {
"build": "../../scripts/build.sh",
"build:noWatch": "../../scripts/build.sh",
"prebuild": "../../scripts/prebuild.sh"
},
Run Code Online (Sandbox Code Playgroud)
然后在root/scripts/build.sh
:
#!/bin/sh
babel src --out-dir lib --root-mode upward --ignore '**/*.test.js','**/__tests__' --watch --verbose
Run Code Online (Sandbox Code Playgroud)
虽然这有效,但感觉不对:它仍然涉及包之间的重复,并且需要设置shell脚本的权限(这使CI复杂化).
有没有更好的方法在我的所有包中共享这些命令?
我有一个带有image_id
财产的模型.我有一个包含图像元素的模型视图.我需要将id插入到image元素的src
属性中以完成图像的URL,这样我才能有效地执行此操作:
<img src="news + newsItem.imageID + .jpg"></img>
Run Code Online (Sandbox Code Playgroud)
我的第一次尝试使用了Handlebars助手:
<img src="news{{newsImageURL newsItem.imageID}}.jpg"></img>
Run Code Online (Sandbox Code Playgroud)
但是这也在它周围插入了Metamprph脚本标签:
<img url="<script id='metamorph-10-start' type='text/x-placeholder'></script>news/7.jpg<script id='metamorph-10-end' type='text/x-placeholder'></script>" alt="" class="content-image news-media" /></a>
Run Code Online (Sandbox Code Playgroud)
所以我看了一下使用bindAttr
,但是因为我需要转换image_id值(通过前置和附加路径的其余部分),这似乎也不是解决方案.
我有以下内容Procfile
:
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
redis: bundle exec redis-server /usr/local/etc/redis.conf
worker: bundle exec sidekiq
Run Code Online (Sandbox Code Playgroud)
跑步$ foreman start
启动Unicorn,Redis和Sidekiq,但我应该如何再次阻止他们?
杀死福尔曼让所有三个人都离开了.我可以看到这个使用ps
:
$ ps aux | grep redis | grep -v grep
me 61560 0.0 0.0 2506784 1740 s000 S+ 9:36am 0:01.28 redis-server /usr/local/etc/redis.conf
$ ps aux | grep sidekiq | grep -v grep
me 61561 0.0 1.0 2683796 173284 s000 S+ 9:36am 0:14.18 sidekiq 2.17.0 pathways [0 of 25 busy]
$ ps aux …
Run Code Online (Sandbox Code Playgroud) 当我生成一个新的Rails 4项目时,Gemfile看起来像这样:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read …
Run Code Online (Sandbox Code Playgroud) ruby ×3
iphone ×2
objective-c ×2
app-store ×1
bem ×1
bundler ×1
cocoa ×1
css ×1
ember.js ×1
foreman ×1
gem ×1
inheritance ×1
ios ×1
javascript ×1
lerna ×1
logging ×1
mapkit ×1
model ×1
monorepo ×1
nested ×1
npm-scripts ×1
package ×1
performance ×1
procfile ×1
sinatra ×1
submission ×1
uiimage ×1
uiimageview ×1
uitableview ×1
version ×1
wrapper ×1