小编den*_*kov的帖子

我可以使用addOperationWithBlock取消添加到NSOperationQueue的块吗?

我读了很多文章说"块是未来!!!".我想知道它是否与后台运行操作有关.

例如,我有一个表视图,其中包含来自Web的图像.现在我可以使用它们+[NSOperationQueue addOperationWithBlock:].当单元格变为可见时,操作将被发送到队列.但是有一种方法可以在单元格从屏幕滚动后取消它吗?或者是进行子类化的唯一方法NSOperation?使用块是很容易的,所以我只是提出这个问题之前,我试图解决这个例子中NSOperation子类...

cocoa-touch nsoperation nsoperationqueue ios objective-c-blocks

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

Yosemite Apache,PHP信息页面未显示

不确定这个问题是否适用于SO所以如果不是,请不要对我大喊......

我已经摆脱了XAMPP并试图在os x中做所有事情.我遵循了许多指南,但我坚持让PHP工作,浏览器不显示phpinfo.我在10.10,Apache/2.4.9,PHP 5.5.14.

我在conf文件中启用了模块,我进入"localhost/~me /"页面,向我显示目录.我的index.php文件包含<?php phpinfo(); ?>,但它只输出原始代码而不是信息.主引导我一直在下面.如果需要任何其他信息,请告诉我,我会提供.每个指南都在这里结束了信息应该显示...任何想法为什么它不工作?

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see 
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you …
Run Code Online (Sandbox Code Playgroud)

php apache macos osx-yosemite

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

使用 UITextPosition,从 textInRange 获取上一个字符

我一直在寻找高低,无法弄清楚如何做到这一点。假设我有一个这样的字符串:

NSString *string = @"&foo !foo";
Run Code Online (Sandbox Code Playgroud)

我想要做的是区分文本视图中的两个 foos(听起来很有趣,哈哈)。当我点击一个时,我想知道它之前是哪个(& 或 !)。这是我如何理解这个词:

UITapGestureRecognizer *recognizer = (UITapGestureRecognizer *)sender;
UITextView *TV = (UITextView*)recognizer.view;
CGPoint location = [recognizer locationInView:TV];
location.y += TV.contentOffset.y;
UITextPosition *tapPosition = [TV closestPositionToPoint:CGPointMake(location.x, location.y)];
UITextRange *textRange = [TV.tokenizer rangeEnclosingPosition:tapPosition 
    withGranularity:UITextGranularityWord inDirection:UITextLayoutDirectionRight];
NSString *tappedWord = [TV textInRange:textRange];
Run Code Online (Sandbox Code Playgroud)

我不知道如何获得前一个字符。TV.tokenizer UITextGranularityCharacter只得到最接近的字母,而不是符号。对此有任何解决方案吗?

objective-c nsstring uitextview ios

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

UICollectionView indexPath.row或item,项目不稳定,跳转

我创建了一个集合视图,我正在将图像加载到其中.问题我正在运行的是当我点击一个单元格来获取它的indexPath.item或indexPath.row时,数字都被搞砸了.单击第一个图像不显示任何内容,单击下一个图像将给我0.点击第三个将给我1,然后单击第二个给我一个2.这在整个视图中都会发生.我必须做错事.这是我的代码:

viewDidLoad中:

UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
layout.sectionInset = UIEdgeInsetsMake(10, 20, 10, 20);
[layout setItemSize:CGSizeMake(75, 75)];
self.images = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 230, self.view.frame.size.width, 200) collectionViewLayout:layout];
self.images.delegate = self;
self.images.dataSource = self;
[self.images registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellIdentifier"];
[self.view addSubview:self.images];
Run Code Online (Sandbox Code Playgroud)

委托方法:

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.imagesGallery.count; //image paths for server
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
    cell.layer.borderWidth = 1;
    cell.layer.borderColor = [[UIColor whiteColor]CGColor];
    UIImageView *image = [[UIImageView alloc]init];
    image.image = [UIImage imageWithData:[self.imagesGallery objectAtIndex:indexPath.row]];
    image.frame = CGRectMake(0, …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uicollectionview uicollectionviewcell uicollectionviewlayout

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

插入函数时出现mysql版本错误

我正在解析一个feed,我想将它插入到我的数据库中.我回显了正确的feed条目,但当我想插入数据库时​​,我收到此错误:

您的SQL语法有错误; 检查与MySQL服务器版本对应的手册,以便在第1行的"更新,链接"VALUES(...)附近使用正确的语法.

这是代码:

include_once("connect_to_mysql.php");

$xml= simplexml_load_file('http://somefeed/feeds/rss');
$list = $xml->entry;
$title = $list[0]->title;
$img = $list[0]->summary->div->img['src'];
$update = $list[0]->updated;
$link = $list[0]->link['href'];

$sql = mysql_query("INSERT INTO table (title, img, update, link) 
VALUES ('$title', '$img', '$update', '$link')") or die (mysql_error());
Run Code Online (Sandbox Code Playgroud)

这在我的网站上运行良好,但现在我收到此错误.我正在使用xampp.还有一些条目是http://的文件,问题是什么?我发现了类似的帖子,但他们的修复程序对我不起作用.

php mysql sql feed

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

MySQL 5.7将键/值附加到嵌套的json对象

我正在尝试mysql 5.7的新API,该API处理JSON列。我的test专栏看起来像这样:

{"foo":{"efg":1}, "bar":{"abc":0}}
Run Code Online (Sandbox Code Playgroud)

我想做的就是附加到其中一个键上,例如,foo这样将导致"foo":{"efg":1, "klm":2}。到目前为止,我一直在尝试遵循他们的文档

mysql> select json_insert(test, '$.foo', 10, '$.foo.klm', 2) from table1
       where name='Joe';
Run Code Online (Sandbox Code Playgroud)

所做的就是替换"efg":1,结果是"foo":{"klm":2}

mysql> select json_array_append(test, '$.foo', '{"klm":2}') from table1 where
       name="Joe';
Run Code Online (Sandbox Code Playgroud)

上面的行显然转换foo为数组"foo":[{"efg":1}, {"klm":2}],这不是我想要的。

我试过将查询组合在一起:

mysql> select json_insert(test, '$.foo', 10, '$.foo', 
       select json_merge(select json_extract(test, '$.foo') from table1 
       where name="Joe"), '{"klm":2}') from table1 where name="Joe";
Run Code Online (Sandbox Code Playgroud)

那只是给我一个语法错误 near select json_extract(test, '$.foo')

任何建议将不胜感激。

mysql json mysql-5.7

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