小编gun*_*171的帖子

CS193P作业3,提示#5 - 型号是什么?

我正在通过2011年斯坦福秋季iOS课程:http: //www.stanford.edu/class/cs193p/cgi-bin/drupal/

我到作业#3: http://www.stanford.edu/class/cs193p/cgi-bin/drupal/system/files/assignments/Assignment%203_2.pdf

作为总结,先前的任务已经要求建立一个常规计算器,现在这个任务要求我们将这个计算器推送到一个Nav控制器并从该CalculatorViewController创建一个segue到GraphViewController,它将绘制存储在"CalculatorBrain"中的函数.这个CalculatorBrain是原始CalculatorViewController的模型.

提示#5继续谈论的事实是,现在GraphViewController的模型与CalculatorViewController的模型不同,我无法弄清楚他的意思.

我能够构建新MVC的唯一方法是在GraphViewController的GraphView(视图)中创建一个带有ID类型为"dataSource"的对象的协议.然后在GraphViewController中:采用该协议,实例化GraphView并将自身设置为数据源:

-(void) setGraphView:(GraphView *)graphView
  {
  _graphView=graphView;   
  self.graphView.dataSource=self;
  }
Run Code Online (Sandbox Code Playgroud)

然后在原始的CalculatoViewController中,使用prepareForSegue将程序传递给GraphViewController:

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
  if([segue.identifier isEqualToString:@"Graph"])
  {
    GraphViewController *myGraphViewController = segue.destinationViewController;
    myGraphViewController.myCalculator=self.myCalcBrain;
  }
}
Run Code Online (Sandbox Code Playgroud)

所以这似乎工作正常.所以,如果这样做,那意味着GraphViewController的模型真的是原来的计算器大脑,他特别说它不是!

我的意思是,在segue期间,我将从原始的CalculatorViewController分配给Graphviewcontroller计算器属性计算器模型实例,然后使用协议将GraphViewController中的Y值返回到GraphView意味着该模型GraphViewController实际上只是原始的CalculatorBrain模型.

model-view-controller objective-c cs193p ios

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

导出到csv wordpress

我需要在csv文件中的一个表中导出数据.我能够很好地获取数据,但浏览器不会生成CSV文件.

我的代码是这样的:它的标题问题.我只得到逗号分隔值的输出,但没有得到csv文件.

/* Converting data to CSV */

public function CSV_GENERATE($getTable)
{
    ob_clean();
    global $wpdb;
    $field='';
    $getField ='';

    if($getTable){
        $result = $wpdb->get_results("SELECT * FROM $getTable");
        $requestedTable = mysql_query("SELECT * FROM ".$getTable);
        // echo "hey";die;//var_dump($result);die;

        $fieldsCount = mysql_num_fields($requestedTable);

        for($i=0; $i<$fieldsCount; $i++){
            $field = mysql_fetch_field($requestedTable);
            $field = (object) $field;         
            $getField .= $field->name.',';
        }

        $sub = substr_replace($getField, '', -1);
        $fields = $sub; # GET FIELDS NAME
        $each_field = explode(',', $sub);
        $csv_file_name = $getTable.'_'.date('Ymd_His').'.csv'; 
        # CSV FILE NAME WILL BE table_name_yyyymmdd_hhmmss.csv

        # GET FIELDS …
Run Code Online (Sandbox Code Playgroud)

php csv wordpress header

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

C++源文件中的不可打印(0xFF)字节

这个特定的C++代码项目具有0xFF字节标记,用于为函数定义添加前缀.

这样做的目的是什么?它是否有助于一些简单的源文件解析器?

显然,编译器会忽略这些标记.

出现在C源文件中的奇怪字符

c++ editor

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

如果未设置,ListItem.Value将覆盖Text

如果设置ListItem.Value设置它的前一个值Text的值,都TextValue将被设置为相同的值.我可以解决这个问题,但我只是想知道为什么会这样?这是因为"必须"设置在屏幕上吗?以及为什么在默认为空字符串时覆盖.

.Net 3.5

ListItem li = new ListItem();
li.Value = "abc"; //Text is now = "abc"
li.Text = "def";
li.Value = "qwe"; //Text remains "def"
Run Code Online (Sandbox Code Playgroud)

c# asp.net

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

无法创建"匿名类型"类型的常量值

我有两个linq查询.我想在另一个查询中使用一个查询的结果.

var t2s = (from temp3 in _ent.Products                       
           where temp3.Row_Num == 2
           select new { temp3.ProductID });
Run Code Online (Sandbox Code Playgroud)

然后我在另一个查询中使用此var:

var _query = (from P1 in _ent.brands
              join temp2 in on 
                  new { Produ_ID = (Int32?)P1.Prod_ID } 
                  equals new { Produ_ID = (Int32?)temp2.ProductID }
             );
Run Code Online (Sandbox Code Playgroud)

当我自己运行第一个查询时,它给了我正确的结果.如果我运行第二个没有join它给我正确的结果,但有一个join给我以下错误:

错误:无法创建"匿名类型"类型的常量值.在此上下文中仅支持原始类型(例如Int32,String和Guid')

.net c# linq-to-entities entity-framework anonymous-types

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

仅匹配换行符

我有一个文本文件,其中包含由换行符分隔的数据行.我要做的是计算文件中的行数,不包括仅作为换行符的行数.

我正在尝试使用正则表达式来查看读取的每一行,如果它以换行符开头,不包括在我的行计数中,但我似乎无法让它工作.我已经到处搜索了如何做到这一点没有结果.

这是我为了尝试这样做而编写的方法:

public int LineCounter()
{
    StreamReader myRead = new StreamReader(@"C:\TestFiles\test.txt");
    int lineCount = 0;
    string line;

    while ((line = myRead.ReadLine()) != null)
    {
        string regexExpression = @"^\r?\n";
        RegexOptions myOptions = RegexOptions.Multiline;
        Match stringMatch = Regex.Match(line, regexExpression, myOptions);
        if (stringMatch.Success)
        {
        }
        else 
        {
            lineCount++;
        }
    }
    return lineCount;
}
Run Code Online (Sandbox Code Playgroud)

我试着改变RegexOptions之间SinglelineMultiline中,我试图把"\r|\n|\r\n"在我的模式匹配,我已经试图消除^从表情,但我似乎无法得到它的工作.无论我做什么,我lineCount总是最终成为文件中的总行数,包括换行符.

我显然忽略了一些明显的东西,但我还不熟悉C#语言,看看有什么不对.一切看起来应该对我有用.有人可以帮帮我吗?

c# regex newline

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

在Excel中格式化带有时区的日期的代码

我有一个时区的日期值。

2005年11月24日GMT + 05:30

Excel中此自定义格式的格式代码是什么?

我试图dd MMM yyyyzzzzzz,和Z,但Excel中忽略这些选项。

excel date-formatting

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

无法连接到redis服务器; 要创建断开连接的多路复用器,请禁用AbortOnConnectFail.PING上的SocketFailure

我试图做一个从azure redis缓存读取和写入的简单示例,我得到这个错误

StackExchange.Redis.dll中出现"StackExchange.Redis.RedisConnectionException"类型的异常,但未在用户代码中处理

附加信息:无法连接到redis服务器; 要创建断开连接的多路复用器,请禁用AbortOnConnectFail.PING上的SocketFailure

我正在使用的代码就是这个,我更改了dns和密码

// Get Connection instance
ConnectionMultiplexer connection = ConnectionMultiplexer
    .Connect("xx.redis.cache.windows.net,ssl=false,password=...");
// Get database
IDatabase databaseCache = connection.GetDatabase();
// Add items
databaseCache.StringSet("foo1", "1");
databaseCache.StringSet("foo2", "2");
// Add items with experation value
databaseCache.StringSet("foo3", "3", TimeSpan.FromMinutes(20));

Stopwatch sw = new Stopwatch();

sw.Start();

// Get item value
string foo1Value = databaseCache.StringGet("foo1");

sw.Stop();

Console.WriteLine("Elapsed={0}", sw.Elapsed);
return View();
Run Code Online (Sandbox Code Playgroud)

c# asp.net azure redis stackexchange.redis

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

正则表达式在字符串中查找单词

我试过了,^name&但它不起作用。怎么在里面找到名字hello-my-name-is

php regex

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

PHP函数声明上面的奇怪评论

我注意到很多脚本都有这些类型的注释:

/**
 * Retrieve list of themes with theme data in theme directory.
 *
 * The theme is broken, if it doesn't have a parent theme and is missing either
 * style.css and, or index.php. If the theme has a parent theme then it is
 * broken, if it is missing style.css; index.php is optional. The broken theme
 * list is saved in the {@link $wp_broken_themes} global, which is displayed on
 * the theme list in the administration panels.
 * …
Run Code Online (Sandbox Code Playgroud)

php comments

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