小编BB_*_*Dev的帖子

如何在Swift中获取内存使用情况

我需要在Swift中以编程方式获取我的应用程序的内存使用量(MB).我找到了Objective-C的示例代码.任何人都可以帮助我将其转换为Swift.谢谢!

void report_memory(void) {
  struct task_basic_info info;
  mach_msg_type_number_t size = sizeof(info);
  kern_return_t kerr = task_info(mach_task_self(),
                             TASK_BASIC_INFO,
                             (task_info_t)&info,
                             &size);
  if( kerr == KERN_SUCCESS ) {
    NSLog(@"Memory in use (in bytes): %u", info.resident_size);
  } else {
    NSLog(@"Error with task_info(): %s", mach_error_string(kerr));
  }
}
Run Code Online (Sandbox Code Playgroud)

iphone ios swift

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

提出半尺寸的模态视图控制器

我试图modal view controller在另一个UIViewController大小的半父视图控制器上实现呈现为:

class ViewController: UIViewController, UIViewControllerTransitioningDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func tap(sender: AnyObject) {
        var storyboard = UIStoryboard(name: "Main", bundle: nil)
        var pvc = storyboard.instantiateViewControllerWithIdentifier("CustomTableViewController") as UITableViewController

        pvc.modalPresentationStyle = UIModalPresentationStyle.Custom
        pvc.transitioningDelegate = self
        pvc.view.backgroundColor = UIColor.redColor()

        self.presentViewController(pvc, animated: true, completion: nil)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? {
        return HalfSizePresentationController(presentedViewController: presented, presentingViewController: presenting)
    }
}

class HalfSizePresentationController : UIPresentationController …
Run Code Online (Sandbox Code Playgroud)

ios swift

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

在BlackBerry中对String数组进行排序

我需要String按升序对以下数组进行排序.

String str[] = {"ASE", "LSM", "BSE", "LKCSE", "DFM"};
Run Code Online (Sandbox Code Playgroud)

怎么做?我需要帮助.

blackberry blackberry-jde

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

标签 统计

ios ×2

swift ×2

blackberry ×1

blackberry-jde ×1

iphone ×1