问题标签 [init]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
914 浏览

objective-c - 如何在Objective-C中用“超类的现有对象”初始化子类的对象

我有子类 NSException 类来创建 CustomException 类。

每当我在代码中(在@catch 中)捕获异常时,我想使用作为参数传递给@catch 的NSException 对象来初始化CustomException 对象(NSException 的子类)。

像这样的东西

我尝试通过将 NSException 对象传递给 CustomException 的 init 方法来做到这一点。(我用传递的 NSException 对象替换了 [super init],如下所示)

这行不通!我怎样才能做到这一点?

提前致谢

0 投票
2 回答
2612 浏览

python - 如何在 Python 中修补 __init__ 模块?

我知道,我知道,它很脏。我想知道是否可以劫持__init__Python 模块的模块以自己替换它。

我之所以这样问是因为我需要阻止 django lib 启动它的 init 进程的某些部分,使其与我们的配置一起崩溃。

是的,最好修复 django 库并发回补丁。是的,我正在与作者联系。但现在,我需要快速修复。

0 投票
7 回答
14371 浏览

python - Pycharm(Python IDE)不会自动完成 Django 模块

我的 Python IDE (pycharm) 已停止自动完成我的模块(建议)。在我尝试导入的每个 django 模块之后,我都会得到未解析的引用:

from django- 有效,但是一旦我添加一个“点”它就会失败,所以from django.db import models给了我未解决的错误......

公认的事情是在编译参考后确实可以工作。

我发现我的所有__init__.py文件(无处不在)不再标有 python 图标,现在是记事本图标。在我的解释器中打开初始化文件也会给出非颜色标记的文本(没有语法突出显示)。所以我认为 Python 不能识别这些文件。

我的python解释器是带有Django 1.2.4的python 2.6.1,我的django安装在:( /Lib/python/2.6/site-packages完整目录,而不是egg)

当我从 IDE 中的外部库展开站点包时,我确实看到所有 .py 文件(除了文件)的彩色标记__init__.py。因此,这就是问题所在。

(我在谷歌上找到了类似问题的帖子,但没有答案......)

0 投票
4 回答
434 浏览

iphone - 我怎样才能分配和初始化一个对象,所以当 ViewDidLoad 加载时它不应该再次重新加载?

我已经在ViewControllerViewDidLoad中初始化了一个委托对象,但是当我再次加载它时,它再次初始化了该值。

我在该委托对象中保存了某种数组,我想使用getObjectand访问它setObject。我应该怎么做才能使委托对象不会在每次ViewDidLoad调用时都重新初始化?

0 投票
1 回答
983 浏览

objective-c - 还发现'-(void) init'

我构建了一个名为 game 的自定义类:

。H

在这里我有一个还找到'-(void) init'

.m

当我尝试使用以下方法初始化对象时:

我得到“找到多个名为'-init'的方法所以我不知道错误在哪里......

0 投票
2 回答
2953 浏览

init - Mariadb 初始化脚本

我在 debian 上安装了 MAriadb 表单源。我使用了初始化脚本mysql.server。

运行时出现该错误:
Starting MySQL
.Manager of pid-file quit without updating file. ... failed!

任何地方都没有mysqld.pid,也没有执行mysqld。

.err 文件: 110209 17:04:55 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
110209 17:04:55 [ERROR] Can't find messagefile '/usr/share/mysql/english/errmsg.sys'
110209 17:04:55 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to
create it.
110209 17:04:55 [Note] PrimeBase XT (PBXT) Engine 1.0.11-7 Pre-GA loaded...
110209 17:04:55 [Note] Paul McCullagh, PrimeBase Technologies GmbH,
http://www.primebase.org
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Compressed tables use zlib 1.2.3.4
110209 17:04:55 InnoDB: highest supported file format is Barracuda.
110209 17:04:55 Percona XtraDB (http://www.percona.com) 1.0.13-11.6 started; log sequence number 45356
110209 17:04:55 [ERROR] Aborting

110209 17:04:55 InnoDB: Starting shutdown...
110209 17:04:55 InnoDB: Shutdown completed; log sequence number 45356
110209 17:04:55 [Note] PrimeBase XT Engine shutdown...
110209 17:04:55 [Note]
110209 17:04:55 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

任何想法 ?

谢谢

0 投票
5 回答
3016 浏览

zend-framework - 如何在所有控制器的 init() 函数中运行相同的行?

我的所有控制器都需要相同的 2 行,每个控制器都有自己的初始化逻辑,但是这两行对所有控制器都是通用的。

如何避免重复代码?

更新:

好的,FlashMessenger 只是一个例子,假设我需要在每个动作中写一个日志行,除了'someAction'@'someController'。所以新的共同路线应该是。

问题是,我应该将这些行放在哪里以避免在每个控制器的所有 init() 中重复它们。这些行应该放在 bootstrap?。如果是这样:如何跳过“someAction”的日志行。或者我应该实现一个“BaseController”并让我的所有控制器都从它扩展。如果是这样:我如何自动加载它?(致命错误:找不到类“BaseController”)。

0 投票
2 回答
8026 浏览

android - Android init.rc 在服务退出时触发

我能够从 Android 中的初始化脚本 (init.rc) 启动我自己的服务,遵循以下指南:http ://www.androidenea.com/2009/08/init-process-and-initrc.html或官方文档位于https://android.googlesource.com/platform/system/core/+/froyo-release/init/readme.txt

有一个名为“on service-exit-< name >”的触发器,其中name是在执行此触发器的操作之前必须退出的服务的名称。但是,此触发器似乎不起作用。我启动了一个小的 shell 脚本作为服务,并相应地创建了触发器以在之后启动所有剩余的服务。执行我的脚本后,init 进程似乎卡住了,无法继续使用剩余的服务。

最终目标是实现类似受控或“分阶段”的引导过程,我可以确保首先执行此脚本,然后启动剩余服务。我也尝试通过使用不同的服务类来实现这一点,但失败了

对此主题的任何帮助表示赞赏。

0 投票
4 回答
136833 浏览

python - Python中的继承和init方法

我是python的初学者。我无法理解继承和__init__().

结果:8

还行吧。但我替换Num2

结果:Error. Num2 has no attribute "n1".

在这种情况下,如何Num2访问n1

0 投票
2 回答
1911 浏览

java - Simpler init script for Java daemons?

I've written a small library for creating services/daemons in Java. The idea is simple. When you start your application you pass a command and a port number. If the command is a start command, a new instance of your application will be started on the specified port. Otherwise, the command will be sent to any instance that might be running on that port.

In short, the library provides a daemonize method that starts a daemon controller thread. It uses sockets to make your application communicate with instances of itself (as you've probably already figured out).

For clarity, here's an example of how you would use it:

The library works really well and I've used it to create a couple of daemons that will run on a Linux server. What's missing now is some scripts to let the admins control these daemons like they control other daemons on the server (e.g. start at boot).

Unfortunately my *nix skills, especially when it comes to scripting, are not top level. I have a basic understanding of the BSD-style init procedure (rc.d), but looking at sample scripts like this one I feel a little lost.

So my question is, isn't there a simpler way to do this in my case? I mean, my daemons already understand the commands and should themselves be responsible for any actions (except in the case where a daemon doesn't respond to stop - it should then be killed after some timeout).