问题列表 - 第18746页

使用Cocoa Touch教程:在iPhone OS上提取地址簿地址值

我已经按照以下教程,在模拟器中它工作得很好,但是在我的手机上选择地址时,谷歌地图发布,我想我已经炒了我的大脑.我将它与NavBarContolloer结合使用任何帮助都会很棒.

摘自:Cocoa Touch教程:在iPhone OS上提取地址簿地址值

这是代码:

#import "RootViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
#import "FourthViewController.h"


@implementation ThirdViewController

@synthesize fourthViewController;
@synthesize firstName;
@synthesize lastName;
@synthesize addressLabel;

-(IBAction)switchPage:(id)sender
{
    if(self.fourthViewController == nil)
    {
        FourthViewController *fourthView = [[FourthViewController alloc]
                                          initWithNibName:@"FourthView" bundle:[NSBundle mainBundle]];
        self.fourthViewController = fourthView;
        [fourthView release];
    }

    [self.navigationController pushViewController:self.fourthViewController animated:YES];
}

-(IBAction)getContact {
    // creating the picker
    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
    // place the delegate of the picker to the controll
    picker.peoplePickerDelegate = self;

    // showing the picker
    [self presentModalViewController:picker animated:YES];
    // …
Run Code Online (Sandbox Code Playgroud)

iphone

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

如何用非单词标记识别文本中的单词?

我目前正在解析一堆邮件,并希望从邮件中获取单词和其他有趣的标记(即使拼写错误或字符和字母的组合,如"zebra21"或"customer242").但我怎么知道"0013lCnUieIquYjSuIA"和"anr5Brru2lLngOiEAVk1BTjN"不是单词而且不相关?如何提取单词并丢弃编码错误或pgp签名部分或我们在邮件中获得的其他内容的令牌,并知道我们永远不会对这些令牌感兴趣?

algorithm nlp lexical-analysis

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

盐渍算法强度

这三种方法制造盐有哪些优点/缺点?

$salt = md5($password);

$salt = sha1(md5($password));

$salt = generate_random_number();
Run Code Online (Sandbox Code Playgroud)

计算哈希:

$hash = sha1($salt + $password);
Run Code Online (Sandbox Code Playgroud)

php cryptography salt

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

设计问题 - 观察者,工厂,组成等

所以我需要设计类似的东西:

我有一个电子表格,可以包含许多表(可能是不同种类).

每张纸都说1A-9Z细胞.

在每个单元格中我可以有一个上面的字符串:字符串,数字,公式 - 这意味着单元格获得像+, - ,/,*等...和单元格数字的操作,并在单元格中我有操作的结果.

我需要设计类,所以将来我可以添加其他类型的单元格(除了字符串/数字/公式)并在公式中添加不同类型的操作 - 所有操作都很简单.

你会如何设计它?

我虽然喜欢这样的事情:

class SpreadSheet
{
  private:

  vector<Isheet> sheets;

  public:

  write(Isheet sheet,int CellNum,ICell value);
  GetValue(Isheet sheet,int CellNum,ICell value);
  AddSheet(ISheet sheet);

 };


  class Isheet
  {
    vector<ICell> cells; // can i do something like that ? cause ICell is a template      
  };

 template<class T>
 class ICell
 {

   Vector<Iobserver> observers;

   public:
    T GetValue() {return m_value;};
    SetValue(T val) {m_value=val;};
    AddObserver(Iobserver obs);
    NotifyAll();
    GetPos() {return m_pos;};


   private:
    T m_value;
    int m_pos;

   };


  class CInt : …
Run Code Online (Sandbox Code Playgroud)

c++ oop design-patterns class

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

bash:使用双引号参数调用脚本

我有一个bash脚本,一个用双引号括起来的参数,它在给定的边界内创建一个map的形状文件,例如

$ export_map "0 0 100 100"
Run Code Online (Sandbox Code Playgroud)

在脚本中,有两个select语句:

select ENCODING in UTF8 WIN1252 WIN1255 ISO-8859-8;
...
select NAV_SELECT in Included Excluded;
Run Code Online (Sandbox Code Playgroud)

当然,这两个语句要求输入输入一个数字作为输入.这可以通过将数字(后跟换行符)连接到脚本来绕过.

为了节省时间,我希望有一个脚本可以创建8个地图 - 每个组合ENCODING(4个选项)和NAV_SELECT(2个选项).

我已经将另一个bash脚本写入create_map服务器作为包装器:

#!/bin/bash

for nav in 1 2 3 4;
do
    for enc in 1 2;
    do
        printf "$nav\n$enc\n" | /bin/bash -c "./export_map.sh \"0 0 100 100\"" 
    done
done
Run Code Online (Sandbox Code Playgroud)

**这有效(谢谢,Brian!),但我找不到"0 0 100 100"从外部脚本外部传递数字参数的方法.**

基本上,我正在寻找在双引号内接受包装器bash脚本的参数的方法,并将它 - 用双引号 - 传递给内部脚本.

澄清:

export_map是主要的脚本,从create_map8次调用.

有任何想法吗? …

bash quotes

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

如何在Google Chrome中没有滚动条的情况下执行window.open

以下代码在Firefox,IE和Opera中打开没有滚动条新窗口.

    var options = {
        height: 300, // sets the height in pixels of the window.
        width: 300, // sets the width in pixels of the window.
        toolbar: 0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
        scrollbars: 0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
        status: 0, // whether a status line appears at the bottom of the window …
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome popup

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

删除用户最佳做法?

我有一个论坛,我允许用户删除他们的帐户.

我希望用户线程仍然存在并显示用户名,但我想知道一件事.

如果一个用户被删除(基本上我只是在表格行中使用他们的用户名和密码,但我保留其他所有内容)而另一个用户正在注册相同的用户名,那么人们会认为具有相同用户名的新用户创建了所有上一个用户创建的线程.

或者不允许新用户选择那些已被删除的用户名?

删除用户的最佳做法是什么?

php mysql

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

在define_method定义的方法上调用super

我创建了一个Model类,我根据在User中调用的方法(属性)定义方法(继承自Model).问题是我无法覆盖define_method定义的方法,并调用super来传递给定义的方法.我想这是因为定义的方法被添加到User本身,而不是模型,所以它实际上没有超类中的方法(即模型).

我想这样做的原因是因为大多数属性应该直接保存到数据库中,而某些属性(如密码)需要一些额外的处理.

class Model
  def self.attribute(name)
    define_method(name) do
      self
    end
  end  
end

class User < Model
  attribute :password
end

class User2 < Model
  attribute :password

  def password
    super
  end
end

@user = User.new
puts @user.password # => <User:0x00000100845540>

@user2 = User2.new
puts @user2.password
# define_super.rb:17:in `password': super: no superclass method 
# `password' for #<User2:0x00000100845578> (NoMethodError)
# from define_super.rb:25:in `<main>'
Run Code Online (Sandbox Code Playgroud)

有什么办法可以改变代码来实现这个目的吗?我需要一种方法来覆盖动态创建的方法.

ruby metaprogramming super superclass

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

编译C程序有多容易?

与此问题相关.编译C程序的过程是什么(假定1个文件)?

c compilation

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

在可分发的Jar文件中打包Android资源文件

我正在研究一些可重用的Android代码,我想将其分发给其他开发人员,以便在他们自己的应用程序中使用.代码有一些资源依赖(layouts,xml和png drawables),我希望能够在单个包(Jar文件)中包含和引用.

这是可能的,如果是这样,最好的方法是什么?

android android-resources

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