标签: rubymotion

如何使用Magical Record创建和更新对象并在不使用contextForCurrentThread的情况下保存它们

我刚刚阅读了MagicalRecord关于为什么contextForCurrentThreadMagicalRecord中不起作用的博客文章的作者.

contextForCurrentThread不推荐使用,saveWithBlock应该使用它,因为它NSManagedObjectContext为相关的线程创建了一个安全的新东西.

contextForCurrentThread到目前为止,我一直在我的应用程序中广泛使用.但是,我无法确定如何使用,saveWithBlock因为我的提取和保存不一定按顺序发生.

目前我正在做的事情如下:

localContext = NSManagedObjectContext.MR_contextForCurrentThread
person = Person.MR_createInContext(localContext)
person.name = "John Smith"

然后,用户可以在app周围浏览,显示不同的控制器,视图等.可以使用与上面的代码类似的方法来创建其他对象.

然后在将来的某个任意点,当用户决定保存时,我运行这个方法:

localContext = NSManagedObjectContext.MR_contextForCurrentThread
localContext.MR_saveToPersistentStoreWithCompletion(
  lambda { |success, error|
    # ...
  }
)
Run Code Online (Sandbox Code Playgroud)

建议和更新对象然后在不使用的情况下保存它们的建议方法是什么contextForCurrentThread

core-data ios magicalrecord rubymotion

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

RubyMotion Build:错误!找不到名为`(?-mix:iOS Team Provisioning Profile)的配置文件

我正在尝试构建一个简单的RubyMotion应用程序,以便我可以在我的iPhone上传输它.

我执行了 rake build:device

    Ankits-MacBook-Pro:hello ankitgupta$ rake build:device
    Build ./build/iPhoneOS-6.0-Development
    Create ./build/iPhoneOS-6.0-Development/hello.app/embedded.mobileprovision
    ERROR! Can't find a provisioning profile named `(?-mix:iOS Team Provisioning Profile)'
Run Code Online (Sandbox Code Playgroud)

对这个错误有什么想法吗?

ruby ios rubymotion

9
推荐指数
3
解决办法
4332
查看次数

更好的VIM自动完成功能

所有,

我已经和vim一起工作了一段时间,并且喜欢它的一切 - 我只有一件事我很想念像RubyMine这样的IDE,那就是高级自动完成功能.

作为参考,这是我的标准VIM设置:https: //github.com/wrwright/.vim

我尝试过使用omnicomplete + supertab的ctags,我想念的一个主要元素是能够调出属性/常量/方法的上下文敏感列表.例如,当我学习RubyMotion时,我很乐意帮助记住iOS SDK常量/属性/方法,但是我的VIM自动完成程序停止了建议的类名.如果它确实建议方法/属性,它列出了大量的方法/属性甚至不适用于我正在使用的类.

我想(简单示例)能够键入UIColor.bl并使用UIColor.blueColor自动完成(或者建议是否有多个选项以"bl"开头,这些选项是UIColor的属性.

RubyMine做得非常好,如果我能让VIM在自动完成方面同样聪明,那将是天堂般的(在学习RubyMotion/iOS开发时也是一个很好的福音.

我也尝试过SnipMate(甚至是https://github.com/rcyrus/snipmate-snippets-rubymotion上的RubyMotion定制变体),但这似乎并没有提供我正在寻找的功能.

ruby vim autocomplete rubymotion

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

使用UIImage的UICollectionView滚动性能很差

我的应用程序中有一个UICollectionView,每个单元格都是UIImageView和一些文本标签.问题是当我让UIImageViews显示他们的图像时,滚动性能很糟糕.它远不如UITableView的滚动体验,甚至没有UIImageView的相同UICollectionView.

我几个月前发现了这个问题,似乎找到了答案,但它是用RubyMotion编写的,我不明白.我试着看看如何将它转换为Xcode,但由于我从未使用过NSCache,所以有点难.海报上有还指出了这里关于实施,除了他们的解决方案的东西,但我不知道在哪里把这些代码要么.可能是因为我不理解第一个问题的代码.

有人能帮助将其翻译成Xcode吗?

def viewDidLoad
  ...
  @images_cache = NSCache.alloc.init
  @image_loading_queue = NSOperationQueue.alloc.init
  @image_loading_queue.maxConcurrentOperationCount = 3
  ...
end

def collectionView(collection_view, cellForItemAtIndexPath: index_path)
  cell = collection_view.dequeueReusableCellWithReuseIdentifier(CELL_IDENTIFIER, forIndexPath: index_path)
  image_path = @image_paths[index_path.row]

  if cached_image = @images_cache.objectForKey(image_path)
    cell.image = cached_image
  else
    @operation = NSBlockOperation.blockOperationWithBlock lambda {
      @image = UIImage.imageWithContentsOfFile(image_path)
      Dispatch::Queue.main.async do
        return unless collectionView.indexPathsForVisibleItems.containsObject(index_path)
        @images_cache.setObject(@image, forKey: image_path)
        cell = collectionView.cellForItemAtIndexPath(index_path)
        cell.image = @image
      end
    }
    @image_loading_queue.addOperation(@operation)
  end
end
Run Code Online (Sandbox Code Playgroud)

以下是第一个问题的提问者解决问题的第二个问题的代码:

UIImage *productImage = [[UIImage alloc] …
Run Code Online (Sandbox Code Playgroud)

performance objective-c rubymotion uicollectionview uicollectionviewcell

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

使用Parse iOS SDK和RubyMotion

RubyMotion提供了销售第三方代码的这些说明:http://www.rubymotion.com/developer-center/guides/project-management/#_files_dependencies

我正在尝试添加Parse.com的iOS SDK.以下是将其添加到XCode项目的说明:https://parse.com/apps/quickstart#ios/existing.但是,因为我正在使用RubyMotion,所以我没有使用XCode.

我在这里记录了我的尝试:https://github.com/adelevie/RubyMotionSamples/commit/603bf4428995bb203cce7e7e8e6989d6e86bda3b

以下是我得到的错误:https://gist.github.com/2595284

ruby xcode parse-platform rubymotion

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

如何使用Rubymotion命令行启动不同的模拟器

Rubymotion,我们开始终端rake

Ankits-MacBook-Pro:Magic ankitgupta$ rake 
     Build ./build/iPhoneSimulator-6.0-Development
  Simulate ./build/iPhoneSimulator-6.0-Development/Magic.app
(main)>
Run Code Online (Sandbox Code Playgroud)

默认情况下它正在启动iPhoneSimulator-6.0-Development.我怎么开始iPhone 5.15.0 Simulator

ruby rubymotion

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

在iOS导航栏中为标题分页效果

如何在iOS中实现分页导航栏标题?也就是说,导航栏中的标题向左或向右滑动,具体取决于您滑动的方式,淡入/淡出取决于您的滑动并被下一个UIPageView标题替换.

Twitter的新iOS应用正是我所指的,对于如何实现这一点的任何想法都非常感激.我附上了一个Twitters应用程序图片的链接

ios rubymotion ios7

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

Selecting the iOS Simulator device type with RubyMotion

Since iOS 8 was released the default device type for simulator became iPhone 6. And even if I manually change the device type using Hardware > Device menu, on the next launch (using rake simulator) the simulator will revert to iPhone 6.

I wonder if there is any rake options, or some other settings to force the device type.

PS. I know that there are ways to force a non-retina iPhone and a way to launch the iPad simulator instead …

iphone ios ios-simulator rubymotion ios8

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

如何在RubyMotion中创建字符串的md5哈希

我有一封电子邮件,想从gravatar.com中提取相应的图片

使用ruby,很容易:

    require 'Digest/md5'

    Digest::MD5.hexdigest("my string")
Run Code Online (Sandbox Code Playgroud)

由于requireRubyMotion中没有方法,如何从电子邮件生成哈希?

ios rubymotion

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

如何在Yosemite中使用"暗模式"使菜单栏应用程序看起来很好?

在开发菜单栏应用程序时,我很难找到使应用程序看起来很好的首选方法.我原本以为Apple控件基本上会在很大程度上处理这个问题,但看起来并非如此.

确保菜单栏应用程序在明暗模式下看起来都很好的首选方法是什么?我是否缺少一些可以更轻松地实现此功能的控制功能,还是需要手动检测模式并适当地修改控件?

cocoa menubar rubymotion osx-yosemite osx-elcapitan

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