首先,我想明确我不是在谈论定义一个协议,而是我理解它的概念
@protocol someprotocol
- (void)method;
@end
Run Code Online (Sandbox Code Playgroud)
我知道Obj-C运行时允许在RUNTIME中创建类,以及它的ivars和方法.也可用于创建SEL-s.我想我只是遗漏了一些东西,但有没有人知道在运行时调用什么函数来创建协议?这个的主要原因是conformsToProtocol:工作,所以只是添加适当的方法并没有真正削减它.
在Vista开发机器上,我成功使用此代码更改用户"管理员"密码:
directoryEntry.Invoke("SetPassword", "new");
Run Code Online (Sandbox Code Playgroud)
当我将它移动到我的Server 2008开发机器上时,代码不起作用,我被迫使用以下代码:
directoryEntry.Invoke("ChangePassword", new object[] { "old", "new" });
Run Code Online (Sandbox Code Playgroud)
我的问题是,为什么?
对于这两种情况,我都是这样创建了DirectoryEntry对象:
DirectoryEntry directoryEntry = new DirectoryEntry(string.Format("WinNT://{0}/{1}", computerName, username));
Run Code Online (Sandbox Code Playgroud)
谢谢!8)
如果你们发现它有用,那就是实际的代码.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.DirectoryServices;
using System.Security.Principal;
namespace AccountMod
{
class Program
{
static void Main()
{
Console.WriteLine("Attempting reset...\n");
try
{
String machineNameAndUser = WindowsIdentity.GetCurrent().Name.ToString();
String machineName = WindowsIdentity.GetCurrent().Name.ToString().Substring(0, machineNameAndUser.IndexOf('\\'));
Console.WriteLine("Computer's name: " + machineName);
ResetPassword(machineName, "Administrator", "new");
//ChangePassword("Administrator", "current", "new"); Console.WriteLine("Finished...");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
Console.WriteLine(e.InnerException); …
Run Code Online (Sandbox Code Playgroud) 我有一个从设计师收到的文本框.但我在GWT写了一个动作.问题是文本框是空的,但是当按下按钮按值填充文本框时,将显示警告框,告知该值已更改.但没有工作.帮助我.
TextBox zip1 = null;
function onModuleLoad() {
zip1 = TextBox.wrap(DOM.getElementById("zip1"));
zip1.addChangeHandler(zip1ChangeAction());
}
private ChangeHandler zip1ChangeAction() {
return new ChangeHandler() {
public void onChange(ChangeEvent event) {
Window.alert("change fired");
}
};
}
Run Code Online (Sandbox Code Playgroud) String match = "hello";
String text = "0123456789hello0123456789";
int position = getPosition(match, text); // should be 10, is there such a method?
Run Code Online (Sandbox Code Playgroud) $ javac ArrayListTest.java
$ java ArrayListTest
$ cat ArrayListTest.java
import java.io.*;
import java.util.*;
public class ArrayListTest{
public static void main(String[] args) {
try {
String hello ="oeoaseu oeu hsoae sthoaust hoaeut hoasntu";
ArrayList<String> appendMe = null;
for(String s : hello.split(" "))
appendMe.add(s+" ");
for(String s : appendMe)
System.out.println(s);
//WHY DOES IT NOT PRINT?
}catch(Exception e){
}
}
}
Run Code Online (Sandbox Code Playgroud) 为我的数据库执行以下方案:
create sequence data_sequence;
create table data_table
{
id integer primary key;
field varchar(100);
};
create view data_view as
select id, field from data_table;
create function data_insert(_new data_view) returns data_view as
$$declare
_id integer;
_result data_view%rowtype;
begin
_id := nextval('data_sequence');
insert into data_table(id, field) values(_id, _new.field);
select * into _result from data_view where id = _id;
return _result;
end;
$$
language plpgsql;
create rule insert as on insert to data_view do instead
select data_insert(new);
Run Code Online (Sandbox Code Playgroud)
然后输入psql:
insert into data_view(field) values('abc');
Run Code Online (Sandbox Code Playgroud)
想看到类似的东西: …
是不是可以在同一显示对象上同时使用CLICK和DOUBLE_CLICK?我试图在双击舞台的阶段添加一个新对象并在舞台上单击一次取消选择所选对象.
似乎DOUBLE_CLICK将同时执行自身以及DOUBLE CLICK路径中的第一个CLICK功能(鼠标按下,鼠标按下,单击,鼠标按下,鼠标按下,双击).
在我编程的其他语言中,有一个内置的计时器,将两者分开.这在AS3中不可用吗?
这是一些代码.基本上我想要的是一个或另一个,而不是双击
stage.doubleClickEnabled = true;
stage.addEventListener(MouseEvent.DOUBLE_CLICK, twoClicks, false, 0, true);
stage.addEventListener(MouseEvent.CLICK, oneClick, false, 0, true);
function oneClick(evt:MouseEvent):void
{
trace("One CLICK");
}
function twoClicks(evt:MouseEvent):void
{
trace("Two CLICKS");
}
//oneClick trace = "One CLICK"
//twoClicks trace = "One CLICK Two CLICKS" (instead of just Two CLICKS)
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用:collection
param在我的RESTful路由中添加自定义路由,map.resources
如下所示:
map.resources :products, :collection => { :tagged => :get }
Run Code Online (Sandbox Code Playgroud)
标记的操作采用:tag参数.我可以使用以下链接到URL路由:
tagged_products_path(:tag => tag.name)
.我的问题是它生成的URL:
/products/tagged?tag=electronic
Run Code Online (Sandbox Code Playgroud)
我希望标签位于URL而不是标签中,如下所示:
/products/tagged/electronic
Run Code Online (Sandbox Code Playgroud)
当然这可以通过一个单独的命名路由来完成,但我想知道我是否遗漏了一些东西,并且有一种方法可以使用:collection
哈希来做到这一点.
在此先感谢您的帮助
-Damien
我目前正在使用......
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
Run Code Online (Sandbox Code Playgroud)
检测滑动.我已经把一切都搞定了.唯一的问题是如果用户触摸某些东西(例如UIButton或其他东西),- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
则不会调用它.是否有类似touchesBegan的东西,但如果我在视图中触摸任何地方,它会起作用吗?
大卫先生,谢谢你
java ×4
objective-c ×2
arraylist ×1
c# ×1
click ×1
double-click ×1
eclipse ×1
gwt ×1
iphone ×1
match ×1
mouseevent ×1
plpgsql ×1
postgresql ×1
protocols ×1
routing ×1
sql ×1
string ×1
textbox ×1
triggers ×1