小编hod*_*smr的帖子

在MIPS中,HI和LO是什么

我正在阅读MIPS中的分区,我发现了div

将$ s除以$ t并将商存储在$ LO中,余数存入$ HI

http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html

维基百科说

HI和LO用于访问乘法器/除法器结果,由mfhi(从高位移动)和mflo命令访问.

http://en.wikipedia.org/wiki/MIPS_architecture

HI和LO寄存器吗?它们是多少个寄存器?

assembly mips cpu-registers

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

为什么C++ int和long类型都是4个字节?

许多来源,包括微软,都将int和long类型都引用为4个字节,并且范围为(带符号)-2,147,483,648到2,147,483,647.如果实际上没有提供更大范围的值,那么拥有长基本类型有什么意义呢?

c++ cpu-architecture

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

点击时,iOS 7 UIBarButtonItem字体会发生变化

我正在尝试更改我的UIBarButtonItem字体.ViewControllers加载时效果很好.但是,如果我点击条形按钮,或向右滑动就像移动到上一个ViewController(但然后回到当前的ViewController),字体会变回系统字体.这是我在AppDelegate中设置的内容:

NSDictionary* barButtonItemAttributes = @{NSFontAttributeName: [UIFont fontWithName:@"SourceSansPro-Light" size:20.0f]};
[[UIBarButtonItem appearance] setTitleTextAttributes: barButtonItemAttributes forState:UIControlStateNormal];
[[UIBarButtonItem appearance] setTitleTextAttributes: barButtonItemAttributes forState:UIControlStateHighlighted];
[[UIBarButtonItem appearance] setTitleTextAttributes: barButtonItemAttributes forState:UIControlStateSelected];
[[UIBarButtonItem appearance] setTitleTextAttributes: barButtonItemAttributes forState:UIControlStateDisabled];
Run Code Online (Sandbox Code Playgroud)

这是我的viewWillAppear的一个例子:

- (void) viewWillAppear:(BOOL)animated {
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStylePlain target:self action:@selector(doneButtonPressed)];
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor colorWithRed:141.0/255.0 green:209.0/255.0 blue:205.0/255.0 alpha:1.0];
}
Run Code Online (Sandbox Code Playgroud)

我是以某种方式改变字体,还是我滥用外观代理?

fonts objective-c uibarbuttonitem ios

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

ARC __block和__weak

假设我正在尝试self从块内访问:

[someObject successBlock:^(NSArray *result) {
    [self someSuccessMethod];
} failure:^(NSString *errorMessage, int status) {
    [self someFailureMethod];
}];
Run Code Online (Sandbox Code Playgroud)

我知道这会创建一个保留周期,someObject并且self永远不会被取消分配.

令我感到困惑的是,有/没有__block关键字的实际情况.我可以通过__weak引用self 来修复保留周期:

__weak MyClass* me = self;
[someObject successBlock:^(NSArray *result) {
    [me someSuccessMethod];
} failure:^(NSString *errorMessage, int status) {
    [me someFailureMethod];
}];
Run Code Online (Sandbox Code Playgroud)

我不需要在__block这里使用,因为我不是想me在块内修改.根据我的理解,如果我不使用__block,me则在块内引用副本.我的问题是:如果块中引用的内容只是对象的副本,为什么原始代码块会创建保留周期?我猜这个引用self只是一个副本,因为我从不使用__block关键字.我错误地想到了这个吗?

objective-c ios automatic-ref-counting

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

在MIPS中创建(和访问)数组

我正在尝试在MIPS Assembly中创建一个数组,然后将所有元素添加到一起.但是,当我尝试组装以下内容时,它说

read_array第1行位置7出错:".word"指令不能出现在文本段中汇编:操作已完成但有错误.

这是我的集会:

list: .word 3, 2, 1, 0, 1, 2
li $t0, 0x00000000  #initialize a loop counter to $t0
li $t4, 0x00000005  #last index of array
li $t3, 0x00000000  #this will hold our final sum
la $t1, list  #the address of list[0] is in $t1

loop: addi $t0, $t0, 0x00000001 #index++
  add $t5, $t0, $t0 #array index X2
  add $t5, $t0, $t0 #array index X2 again
  add $t6, $t5, $t1 #4x array index in $t6

  lw $t2, 0($t6) …
Run Code Online (Sandbox Code Playgroud)

arrays assembly mips mars-simulator

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

无需后端控制即可抓取AJAX应用程序

我已经构建了一个利用EmberJS和GitHub Pages创建在浏览器中呈现的博客应用程序的工具.它使用JavaScript来获取Markdown文件并将它们呈现到应用程序的主体中.由于所有内容都是通过AJAX请求获取的,因此我不确定是否可以通过Google等方式对内容进行抓取.

很多 的文章暗示使用PhantomJS处理_escaped_fragment_请求,但是由于内容是在GitHub上托管,有没有办法运行任何服务器端.

是否有可能解决此问题(例如在将内容推送到GitHub之前提前呈现某些内容)或者我是否只是遇到了JavaScript应用程序的缺点?

javascript ajax seo github ember.js

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

Ruby请求中的User-Agent

我是Ruby的新手.我试过查看在线文档,但我还没有发现任何有用的东西.我想在以下HTTP请求中包含User-Agent,bot get_response()和get().有人能指出我正确的方向吗?

  # Preliminary check that Proggit is up
  check = Net::HTTP.get_response(URI.parse(proggit_url))
  if check.code != "200"
    puts "Error contacting Proggit"
    return
  end

  # Attempt to get the json
  response = Net::HTTP.get(URI.parse(proggit_url))
  if response.nil?
    puts "Bad response when fetching Proggit json"
    return
  end
Run Code Online (Sandbox Code Playgroud)

ruby user-agent http

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

在红宝石中处理来自json的坏UTF-8

我在http://hndroidapi.appspot.com/news/format/json/page/?appid=test从远程json中提取数据.我遇到的问题是这个API似乎正在构建JSON而没有正确处理UTF-8编码(如果我在这里错了,请纠正我).例如,现在传递的部分结果是

{
"title":"IPad - please don€™t ding while you and I are asleep  ",
"url":"http://modern-products.tumblr.com/post/25384729998/ipad-please-dont-ding-while-you-and-i-are-asleep",
"score":"10 points",
"user":"roee",
"comments":"18 comments",
"time":"1 hour ago",
"item_id":"4128497",
"description":"10 points by roee 1 hour ago  | 18 comments"
}
Run Code Online (Sandbox Code Playgroud)

请注意don€™t.而这并不是它窒息的唯一一种角色.鉴于我不控制API,有什么办法可以将数据转换为干净的东西吗?

编辑:

这是我如何拉下JSON:

hn_url = "http://hndroidapi.appspot.com/news/format/json/page/?appid=test"
  url = URI.parse(hn_url)

  # Attempt to get the json
  req = Net::HTTP::Get.new(hn_url)
  req.add_field('User-Agent', 'Test')
  res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) }
  response = res.body
  if response.nil?
    puts "Bad response when fetching HN json"
    return
  end …
Run Code Online (Sandbox Code Playgroud)

ruby encoding json utf-8

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

在iOS上正确处理JSON中的UTF-8

我收到一些有奇怪的UTF-8字符串的JSON.例如:

{
  "title": "It\U2019s The End";
}
Run Code Online (Sandbox Code Playgroud)

处理这些数据的最佳方法是什么,以便以可读的方式呈现?我想将\ U2019转换为它应代表的引号.

编辑:假设我已将字符串解析为NSString*jsonResult

编辑2:我通过AFNetworking收到JSON :

AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    NSString* jsonResult = [JSON valueForKeyPath:@"title"];
} failure:nil];
Run Code Online (Sandbox Code Playgroud)

objective-c utf-8 ios

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

没有检查块

我有一个方法执行异步网络调用,然后通过块传递成功或失败结果:

- (void) loginWithSuccess:(void (^)(id responseObject))success failure:(void (^)(NSError* error))failure {
...
  if(error) {
    failure(error);
  }
  else {
    success(responseObject);
  }
}
Run Code Online (Sandbox Code Playgroud)

我注意到,如果我调用此方法并nil作为我的块传入,我的应用程序将崩溃EXEC_BAD_ACCESS:

[manager loginWithWithSuccess:nil failure:nil];
Run Code Online (Sandbox Code Playgroud)

但是,如果我传入空块,它运行正常:

[manager loginWithWithSuccess:^(id responseObject){} failure:^(NSError *error){}];
Run Code Online (Sandbox Code Playgroud)

我假设这是因为在运行时你不能传递参数nil?因此,在定义采用块的方法时,我应该在调用块之前检查块是否为nil?

objective-c ios objective-c-blocks

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