首页 \ 问答 \ 为什么0代表java.lang.Class.forName0?(Why does the 0 represent in java.lang.Class.forName0? [duplicate])

为什么0代表java.lang.Class.forName0?(Why does the 0 represent in java.lang.Class.forName0? [duplicate])

这个问题在这里已有答案:

我熟悉Java异常的基本结构,但是我第一次注意到Class.forName stacktrace的奇怪之处:

java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:195)
...
java.lang.Thread.run(Thread.java:745)

为什么提到了两个forName实例,零表示什么? 这是堆栈跟踪如何表示具有不同签名的多个同名方法吗?


This question already has an answer here:

I'm familiar with the basic structure of Java exceptions, but for the first time I noticed an oddity with a Class.forName stacktrace:

java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:195)
...
java.lang.Thread.run(Thread.java:745)

Why are there two forName instances mentioned, and what does the zero represent? Is this how stacktraces represent multiple methods of the same name with different signatures?


原文:https://stackoverflow.com/questions/48911403
更新时间:2021-05-15 21:05

最满意答案

您需要将视图存储到属性中,然后在每次触发计时器事件时枚举该属性

var sprites: [UIImageView]?

override func viewDidLoad() {
  super.viewDidLoad()

  var sprite = UIImage(named: "sprites/areaLocatorSprite.png")!

  var locations:NSArray = animal[eventData]["locations"] as NSArray

  self.sprites = map(locations) {
    var locationx = $0["locationx"] as String
    var locationy = $0["locationy"] as String

    let x = NSNumberFormatter().numberFromString(locationx)
    let y = NSNumberFormatter().numberFromString(locationy)
    let cgfloatx = CGFloat(x!)
    let cgfloaty = CGFloat(y!)

    var mapSprite = UIImageView(image: sprite)

    mapSprite.frame = CGRectMake(cgfloatx,cgfloaty,10,10)
    townMap.addSubview(mapSprite)

    return mapSprite
  }

  timer = NSTimer.scheduledTimerWithTimeInterval(0.35, target: self, selector: Selector("flash"), userInfo: nil, repeats: true)
}

func flash() {
  if let sprites = self.sprites {
    for sprite in sprites {
      sprite.alpha = sprite.alpha == 0 ? 1 : 0
    }
  }
}

You need to store the views into a property and then enumerate that property each time your timer event is fired

var sprites: [UIImageView]?

override func viewDidLoad() {
  super.viewDidLoad()

  var sprite = UIImage(named: "sprites/areaLocatorSprite.png")!

  var locations:NSArray = animal[eventData]["locations"] as NSArray

  self.sprites = map(locations) {
    var locationx = $0["locationx"] as String
    var locationy = $0["locationy"] as String

    let x = NSNumberFormatter().numberFromString(locationx)
    let y = NSNumberFormatter().numberFromString(locationy)
    let cgfloatx = CGFloat(x!)
    let cgfloaty = CGFloat(y!)

    var mapSprite = UIImageView(image: sprite)

    mapSprite.frame = CGRectMake(cgfloatx,cgfloaty,10,10)
    townMap.addSubview(mapSprite)

    return mapSprite
  }

  timer = NSTimer.scheduledTimerWithTimeInterval(0.35, target: self, selector: Selector("flash"), userInfo: nil, repeats: true)
}

func flash() {
  if let sprites = self.sprites {
    for sprite in sprites {
      sprite.alpha = sprite.alpha == 0 ? 1 : 0
    }
  }
}

相关问答

更多
  • 我使用这样的代码来实现类似的效果(尽管我将它旋转了360度): CABasicAnimation *rotate; rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; rotate.fromValue = [NSNumber numberWithFloat:0]; rotate.toValue = [NSNumber numberWithFloat:deg2rad(10)]; rotate.duration = 0. ...
  • 我对你如何创建UIImageViews感到有点困惑,因为你使用的是for循环而是静态名称。 所以你可能有15个名为“imageView1”的UIImageViews。 但无论如何,如果您使用链接到的问题中的代码,这根本不重要。 也许你把线条排除在外......这是正确的顺序。 (如果它不起作用,请告诉我,以及你得到的错误) //-(void)ViewDidLoad? {???? is this your function?? int xvalue = 0;//?? not sure where yo ...
  • contentMode本身不是可动画的属性。 但是你可以在具有transition(with:duration:options:animations:completion:)的视图的两个不同再现之间进行动画处理transition(with:duration:options:animations:completion:) ,例如 @IBAction func didTapButton(_ sender: UIButton) { let contentMode: UIViewContentMode = ...
  • UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Trend"]]; imageView.frame = CGRectMake(....) or imageView.center = CGPointMake(...) 将此视图添加到容器视图中,即[myView addSubview:imageView]; UIImageView *imageView = [[UIImageView allo ...
  • 您不需要在animateWithDuration使用CAffineTranform ,您可以简单地定义新中心,如: let oldCenter = image.center let newCenter = CGPoint(x: oldCenter.x - 100, y: oldCenter.y) UIView.animate(withDuration: 1, delay: 0, options: .curveLinear, animations: { image.center = newCenter ...
  • 使用NSValue(CGPoint: cgpiont)而不是NSValue.valueWithCGPoint(<#point: CGPoint#>) ,这在swift中已弃用。 NSValue(CGPoint: cgpiont)是给定的构造函数,可以用来将NSValue中的CGPoint转换为NSValue 。以下代码可以工作 func moveImage(view: UIImageView){ var toPoint: CGPoint = CGPointMake(0.0, -10.0) v ...
  • 您需要将imageView放在最前面,而不是self.view。 self.playerImages[self.currentPlayer].bringSubview(toFront: imageView!) You need to bring the imageView to the front and not self.view. self.playerImages[self.currentPlayer].bringSubview(toFront: imageView!)
  • UIView.animateWithDuration(1, delay: 0, options: .CurveLinear, animations: { UIImageView.center = CGPointMake(UIImageView.center.x, UIImageView.center.y + 200); }, completion: { (finished: Bool) in move(); }); 这是如何。 UIView.animateWithDuration( ...
  • 实现这一目的的一种方法是,您可以首先添加一个视图,并将该视图颜色设置为grayColor ,并在开始时将其隐藏起来,并将其alpha设置为0.8,并且当侧边栏出现时显示该视图以及侧栏隐藏时可以隐藏该视图。 这是一个简单的示例代码: import UIKit class ViewController: UIViewController, sideBarDelegate { var sideBar : SideBar = SideBar() @IBOutlet weak var Trans ...
  • 您需要将视图存储到属性中,然后在每次触发计时器事件时枚举该属性 var sprites: [UIImageView]? override func viewDidLoad() { super.viewDidLoad() var sprite = UIImage(named: "sprites/areaLocatorSprite.png")! var locations:NSArray = animal[eventData]["locations"] as NSArray self.s ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)