问题列表 - 第35182页

为什么会崩溃?

我上了课.这是h文件.

//  MyClass.h
#import <Foundation/Foundation.h>


@interface MyClass : NSObject <NSCoding> {
    NSString *string1;
    NSString *string2;

}
@property (nonatomic, retain) NSString *string1;
@property (nonatomic, retain) NSString *string2;

@end
Run Code Online (Sandbox Code Playgroud)

这是m文件.

//  MyClass.m
#import "MyClass.h"


@implementation MyClass
@synthesize string1, string2;

- (void)encodeWithCoder:(NSCoder *)coder;
{
    if (self = [super init]){
        [coder encodeObject:string1 forKey:@"string1"];
        [coder encodeObject:string2 forKey:@"string2"]; 
    }

}

- (id)initWithCoder:(NSCoder *)coder;
{
    self = [[MyClass alloc] init];
    if (self != nil)
    {
        string1 = [coder decodeObjectForKey:@"string1"];
        string2 = [coder decodeObjectForKey:@"string2"];

    }   
    return self;
} …
Run Code Online (Sandbox Code Playgroud)

crash cocoa-touch objective-c nsuserdefaults nsmutablearray

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

Apache FOP:zindex似乎不在重叠块中工作

我是FOP newb.我试图通过使用块容器和zindexes在图像上显示文本.尽管图像总是在顶部.如果我删除图像,我可以看到文本,因此文本在图像下.

这是一个表格单元格.这是相关代码:

<fo:table-cell padding="0.000pt" text-align="left" display-align="before">
                <fo:block>
                  <fo:block-container z-index="2" position="absolute" left="0.913in" top="0.139in" width="0.946in" height="0.198in" overflow="hidden">
                    <fo:block><fo:inline font-family="Verdana" font-size="8pt">Leasure Station</fo:inline></fo:block>
                  </fo:block-container>

                  <fo:block-container z-index="2" position="absolute" left="0.091in" top="0.431in" width="0.302in" height="0.239in" overflow="hidden">
                    <fo:block><fo:inline font-family="Verdana" font-size="8pt">#1</fo:inline></fo:block>
                  </fo:block-container>

                  <fo:block-container z-index="2" position="absolute" left="0.653in" top="0.431in" width="1.186in" height="0.177in" overflow="hidden">
                    <fo:block><fo:inline font-family="Verdana" font-size="8pt">ASDF1234QWER</fo:inline></fo:block>
                  </fo:block-container>

                  <fo:block-container z-index="1" position="absolute" left="0in" top="0in" width="48.5mm" height="20mm" overflow="hidden">
                    <fo:block><fo:external-graphic src="url(.\fop-1.0\img\orange_s_text.png)" content-width="48.500mm" scaling="non-uniform" content-height="20.000mm"/></fo:block>
                  </fo:block-container>
                </fo:block>
              </fo:table-cell>
Run Code Online (Sandbox Code Playgroud)

pdf-generation xsl-fo apache-fop

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

如何在libpcap中使用"pcap_lookupdev()"?

代码无法找到任何设备,我想知道pcap_lookupdev()做了什么?谢谢

#include <pcap.h>
int main(int argc, char *argv[])
{
    pcap_t *handle;

    char *dev;// = "eth0";
    char errbuf[PCAP_ERRBUF_SIZE];
    dev = pcap_lookupdev(errbuf);
    if (dev == NULL) {
        fprintf(stderr, "Couldn't find default device: %s\n", errbuf);
        return(2);
    }
    printf("Device: %s\n", dev);
    return(0);

    handle = pcap_open_live(dev, BUFSIZ, 1, 1000, errbuf);
    if (handle == NULL) {
        fprintf(stderr, "Couldn't open device %s: %s\n", dev, errbuf);
        return(2);
    }


}
Run Code Online (Sandbox Code Playgroud)

c linux libpcap

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

对如何以及何时使用header()重定向到不同的页面感到困惑?

我一直在我的应用程序中使用header()重定向到不同的页面,看看下面我的代码.我已经把代码放在页面的顶部,我没有使用任何评论

if(isset($_SESSION['loggedin'])){
header("Location: dashboard.php");
exit;
}
else {
require_once('models/validation.php');
require_once('config/database.php');  
Run Code Online (Sandbox Code Playgroud)

我在第50行下面放了一些代码来检查登录凭据并将其重定向到dashboard.php

if( !empty($_POST['username']) || !empty($_POST['password'])) {
if( check_login($_POST['username'], $_POST['password'])) {
    header("Location: dashboard.php");
    exit;    
Run Code Online (Sandbox Code Playgroud)

第一组代码工作正常,因为当我登录并尝试访问index.php时,第一组代码开始生效并将我推回到dashboard.php

当我成功登录时,我面临着下面第二组代码的问题,它没有将我重定向到dashboard.php,而是它给了我以下错误

警告:无法修改标头信息 - 已在/ home/bhatkaln/public_html/test/admin-login/index中发送的标头(在/home/bhatkaln/public_html/test/admin-login/index.php:17中开始输出).第54行的PHP

我哪里错了?是否可以使用header()进行重定向,或者我应该考虑使用替代方法

<meta http-equiv="refresh" content="0;dashboard.php"/>";
Run Code Online (Sandbox Code Playgroud)

编辑:对不起伙计我更新了我的错误代码,这是我的第53,54和55行.

if( check_login($_POST['username'], $_POST['password'])) {
    header("Location: dashboard.php");
    exit;
Run Code Online (Sandbox Code Playgroud)

php

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

如何使用CodeIgniter的LIKE查询?

我想运行这样的查询:

SELECT * FROM table WHERE field LIKE '%search_term%'
Run Code Online (Sandbox Code Playgroud)

在CI中,您可以将参数绑定到查询,如果您使用field=?但这不起作用field LIKE "%?%".从调试输出看来,使用的查询似乎是field LIKE "%'search'%".

有没有其他方法可以在CodeIgniter中进行搜索?

mysql codeigniter sql-like

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

为什么获取外部HTML不起作用?

基于这个问题,我尝试以两种不同的方式获取外部HTML .不幸的是,他们都没有给出预期的结果:

HTML:

<div id='my_div'>Hello</div>
Run Code Online (Sandbox Code Playgroud)

JS:

$(function() {
    document.write('[' + $('#my_div').clone().wrapAll("<div />").parent().get(0).innerHTML + ']<br />');
    document.write('[' + (new XMLSerializer().serializeToString(document.getElementById('my_div'))) + ']');
});
Run Code Online (Sandbox Code Playgroud)

输出是:

[
Hello
]
[
Hello
]
Run Code Online (Sandbox Code Playgroud)

我期待以下结果: <div id='my_div'>Hello</div>

这里有实例

我究竟做错了什么 ?

html javascript jquery outerhtml

6
推荐指数
2
解决办法
5405
查看次数

将(u)int64_t转换为NSNumbers

所以基本上我的问题是,我正在创建一个使用uint64_t对象作为键的NSMutableDictionary.

有没有更好的方法来创建它们而不是这样做?

uint64_t bob=7;

NSNumber *bobsNumber;

#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
bobsNumber=[NSNumber numberWithUnsignedLong:bob];
#else
bobsNumber=[NSNumber numberWithUnsignedLongLong:bob];
#endif
Run Code Online (Sandbox Code Playgroud)

只要你没有将它包含在二进制文件/套接字/ NSData对象/中,这就可以工作.但有没有更好的方法呢?我真的希望确保对象是64位,无论我在哪个平台上运行它.

我想我可以通过总是无条件的长整数来避免整个问题但当然如果我在任何有效数字中分配这些对象,那么在64位机器上浪费了大量的堆空间....

cocoa nsnumber uint64

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

我可以在UNIX shell中执行嵌套或链接命令吗?

我可以在UNIX shell中的另一个命令中执行命令吗?

如果不可能,我可以使用上一个命令的输出作为下一个命令的输入,如:

command x然后command y,

command y我想在哪里使用输出command x

linux ubuntu command-line solaris nested

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

使用 Python 以编程方式检查环境完整性的最佳实践?

我正在构建一个具有 Apache、Postgresql 和 mod_wsgi 等依赖项的系统。作为部署过程的一部分,我想编写一个健全性检查脚本,尝试确定服务器环境是否符合各种假设,其中最基本的是是否安装了依赖项。

我考虑过的检查:

  • 检查服务是否响应,例如发出 HTTP 请求、连接到数据库等。
  • 以某种方式检查服务是否正在运行,例如也许 grep ps ax?(这个好像不太靠谱)
  • 检查软件包是否已安装,例如通过查询 dpkg。

这些显然是按照特异性递减的顺序排列的,希望是如果一个测试失败,我可以通过运行更具体的测试来找出原因。

但我该停在哪里呢?我应该检查多少级别的特异性?是否有做此类事情的最佳实践?

谢谢!

python deployment package

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

C#3.0中使用Property {get,set}方法的用途是什么

可能重复:
C#自动属性

您好,
我最近从Java迁移到.net(c#)平台.在这里,我还没有遇到太多问题......无论如何我搞砸了

                   property{get, set}
方法.实际上我根本无法弄清楚这些(属性)的确切含义.初始化变量或字段或对象状态的相同工作可以使用方法完成.我们可以将字段声明为私有,并可以使用相同类的公共方法访问它们.

           一个简单的事情我不是程序员或员工,而是计算机科学的普通学生,旨在成为一名全职职业的程序员.

- 非常感谢你们所有人提前协助我.

财产{get,set}

c# methods get properties set

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