Re: Inserting a task into the run loop

2015-03-21 Thread Kyle Sluder
On Sat, Mar 21, 2015, at 10:27 PM, Graham Cox wrote: > I have a requirement that runs my code exactly once per run loop, and I'm > wondering what the modern preferred way to do this is. Use a run loop observer? --Kyle Sluder ___ Cocoa-dev mailing list

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Kyle Sluder
On Sat, Mar 21, 2015, at 10:10 PM, Jens Alfke wrote: > > > On Mar 21, 2015, at 8:43 PM, Charles Srstka > > wrote: > > > > If you convert between String and NSString a lot, it’ll have performance > > implications (which is why bridging to NSString just to get -UTF8String > > isn’t really a goo

Inserting a task into the run loop

2015-03-21 Thread Graham Cox
I have a requirement that runs my code exactly once per run loop, and I'm wondering what the modern preferred way to do this is. I've developed the code using a timer with a very fast rate which I know can't really be met, so effectively it's calling back once per loop, but I figure there has t

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Jens Alfke
> On Mar 21, 2015, at 8:43 PM, Charles Srstka wrote: > > If you convert between String and NSString a lot, it’ll have performance > implications (which is why bridging to NSString just to get -UTF8String isn’t > really a good idea). Then what would be the best way, given a String, to pass it

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Quincey Morris
On Mar 21, 2015, at 20:43 , Charles Srstka wrote: > > I’m pretty sure that “real” Swift strings are different from NSStrings at > runtime. It’s not like NSString/CFString; it has to do an actual conversion, > and is not toll-free bridged. If you convert between String and NSString a > lot, it’

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Charles Srstka
> On Mar 21, 2015, at 9:28 PM, Quincey Morris > wrote: > > On Mar 21, 2015, at 18:55 , Charles Srstka > wrote: >> >> The implicit conversions between String and NSString were removed in Swift >> 1.2 > > I’m sorry, I muddied the waters by using an incorrect de

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Quincey Morris
On Mar 21, 2015, at 18:55 , Charles Srstka wrote: > > The thing that’s odd is that the native Swift String’s implementation of > cStringUsingEncoding uses the Foundation NSStringEncoding constants instead > of something that wouldn’t require importing Foundation. > On Mar 21, 2015, at 18:46 ,

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Quincey Morris
On Mar 21, 2015, at 18:55 , Charles Srstka wrote: > > The implicit conversions between String and NSString were removed in Swift 1.2 I’m sorry, I muddied the waters by using an incorrect description of “bridging” earlier. Bridging in Obj-C is something like NSString vs CFString. The types and

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Charles Srstka
> On Mar 21, 2015, at 6:41 PM, Jens Alfke wrote: > >> On Mar 21, 2015, at 2:13 PM, Quincey Morris >> > > wrote: >> >> Well, “String” is not “NSString”. > > Sure, but it’s bridged with NSString. The “Using Swift With Cocoa” book says: > “Swift automa

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Jens Alfke
> On Mar 21, 2015, at 4:58 PM, Quincey Morris > wrote: > > When you used “cStringUsingEncoding”, you weren’t bridging to the NSString > method, you were using String’s native method of the same name. Aha. That was not at _all_ clear from the docs. The implication there is that String inheri

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Jens Alfke
—Jens > On Mar 21, 2015, at 5:09 PM, Kevin Meaney wrote: > > But the bridging only happens if you import Foundation, otherwise there is no > NSString to bridge with. I did import Foundation. I showed that clearly in the code snippets in my first message. --Jens ___

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Kevin Meaney
Sent from my iPad > On 21 Mar 2015, at 23:41, Jens Alfke wrote: > > >> On Mar 21, 2015, at 2:13 PM, Quincey Morris >> wrote: >> >> Well, “String” is not “NSString”. > > Sure, but it’s bridged with NSString. The “Using Swift With Cocoa” book says: > “Swift automatically bridges between th

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Quincey Morris
On Mar 21, 2015, at 16:41 , Jens Alfke wrote: > > Sure, but it’s bridged with NSString. The “Using Swift With Cocoa” book says: > “Swift automatically bridges between the String type and the NSString class. > This means that anywhere you use an NSString object, you can use a Swift > String typ

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Jens Alfke
> On Mar 21, 2015, at 2:13 PM, Quincey Morris > wrote: > > Well, “String” is not “NSString”. Sure, but it’s bridged with NSString. The “Using Swift With Cocoa” book says: “Swift automatically bridges between the String type and the NSString class. This means that anywhere you use an NSString

Re: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Quincey Morris
On Mar 21, 2015, at 14:02 , Jens Alfke wrote: > > let s = “……” > some_function(s.UTF8String) Well, “String” is not “NSString”. So: import Cocoa var str = "Hello, playground” as NSString str.cStringUsingEncoding(NSUTF8StringEncoding) // OK str.UTF8Stri

Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Jens Alfke
I’m writing Swift code to call a C function that takes a string in the form of a char*. The value I have is a String, obviously. I thought this would work: import Foundation let s = “……” some_function(s.UTF8String) but this fails to compile, with an error “‘String’ does not

Re: Cleaning up a project from static/global variables

2015-03-21 Thread Jeffrey Robert Kelley
Eyal, In Xcode, they should appear in the Symbol Navigator (⌘2) under “Globals.” Just verified that, at least in Swift, global variables do appear. You’ll want to use the icons at the bottom to hide system-defined globals, and deselect the left one, which only shows classes and protocol

Re: Cleaning up a project from static/global variables

2015-03-21 Thread Quincey Morris
On Mar 21, 2015, at 12:48 , Eyal Redler wrote: > > I can do a search for "static" but some are plain globals: variables defined > outside of any method. Oh, I thought you meant that you want to find references to (known) globals, but you seem to be saying you want to find all the definitions o

Re: Cleaning up a project from static/global variables

2015-03-21 Thread Gary L. Wade
If you’re wanting to look at all the globals in your project in one place, go to the Symbol Navigator and make sure the Class/Protocol filter is turned off and the Project-Defined filter is turned on. This will give you easy access to your project-defined globals. -- Gary L. Wade http://www.garywa

Re: Cleaning up a project from static/global variables

2015-03-21 Thread Eyal Redler
I can do a search for "static" but some are plain globals: variables defined outside of any method. Eyal > On Mar 21, 2015, at 6:34 PM, Quincey Morris > wrote: > > On Mar 21, 2015, at 09:07 , Eyal Redler wrote: >> >> I have a rather large ObjC and C project that I want to clean-up in orde

Scrolling while resizing a UITableView with UITextFields

2015-03-21 Thread Luther Baker
Hi, I have a question about parallel scrolling (I think) in iOS. Let's say I've got a UITableView with > 20 or so rows where each cell's contentView essentially contains a simple UITextField. Assume I am not using a UITableViewController for the time being (I've actually got 5 of these tableviews

Re: Cleaning up a project from static/global variables

2015-03-21 Thread Quincey Morris
On Mar 21, 2015, at 09:07 , Eyal Redler wrote: > > I have a rather large ObjC and C project that I want to clean-up in order to > make it re-enterent/thread safe. > There are all sorts of issues I need to deal with here but one of the most > troubling is the rather liberal use of static and glo

Cleaning up a project from static/global variables

2015-03-21 Thread Eyal Redler
I have a rather large ObjC and C project that I want to clean-up in order to make it re-enterent/thread safe. There are all sorts of issues I need to deal with here but one of the most troubling is the rather liberal use of static and global variables through the project. Fixing the issues is no

Re: Core Data Model Editor without Core Data

2015-03-21 Thread Jerry Krinock
> On 2015 Mar 20, at 21:25, Roland King wrote: > > I don’t see that Apple has been neglecting Core Data. I hope you are correct. I suppose they were preoccupied with Swift last year. I had a dream last night that we’ll soon get a new “metal” persistent store to replace SQLite, one which is

Re: Scrolling Text Field Class for Logging?

2015-03-21 Thread Dave
Hi, That sort of works - here is the code: myVisibleRect = [[self.pFloatingWindowMonitorScrollView documentView] visibleRect]; myVisibleScrollY = NSMaxY(myVisibleRect); myFrameRect = [[self.pFloatingWindowMonitorScrollView documentView] frame]; myFrameScrollY = NSMaxY(myFrameRect); i