Re: [MORE} startAccessingSecurityScopedResource
On 22 Jan 2014, at 02:46, koko wrote: > I believe I should use contentsOfDirectoryAtURL and then create a > security-scoped bookmark for each file I am interested in and in this manner > I will be able to read the files across launches of the app. > > On Jan 21, 2014, at 7:26 PM, koko wrote: > >> In the code snippet below is it possible to read the files whose names are >> in the NSArray contents? >> >> >> if ( [url startAccessingSecurityScopedResource] ) Where did url come from? Presumably a bookmark, and since you expect it to be a directory, it must be an application-scoped bookmark. -startAccessingSecurityScopedResource will grant your app access to the directory and all the files/folders etc. inside it (recursively). >> { >> NSFileManager *defaultManager = [NSFileManager defaultManager]; >> NSArray *contents = [defaultManager contentsOfDirectoryAtPath:[url >> path] error:&error]; >>[url stopAccessingSecurityScopedResource]; Access is counter-based, so assuming you haven’t got any other calls to -startAccessingSecurityScopedResource for the same location on the go, this line of code has just cut off access. Yes, you could first generate more bookmarks for each of the files inside the directory, but that seems a weird thing to do for most use cases. Instead, just keep access to the directory open until you’re finished with it. >> } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Design by contract and cocoa
Does anyone regularly use design by contract in their Cocoa apps? At present I often make use of NSAssert() et al to validate method inputs as a passing nod to design by contract, but that’s it. I know there are some macros available, http://www.roard.com/contracts/, but I haven’t experimented further as yet Jonathan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [MORE} startAccessingSecurityScopedResource
Mike, thanks for the observations … I now understand the process and yes "you could first generate more bookmarks for each of the files inside the directory, but that seems a weird thing to do” , I had not realized that and I assume this to be true, once -startAccessingSecurityScopedResource is called access is granted to the resource until -stopAccessingSecurityScopedResource. So thanks for looking in … ! -koko On Jan 22, 2014, at 4:04 AM, Mike Abdullah wrote: > On 22 Jan 2014, at 02:46, koko wrote: > >> I believe I should use contentsOfDirectoryAtURL and then create a >> security-scoped bookmark for each file I am interested in and in this manner >> I will be able to read the files across launches of the app. >> >> On Jan 21, 2014, at 7:26 PM, koko wrote: >> >>> In the code snippet below is it possible to read the files whose names are >>> in the NSArray contents? >>> >>> >>> if ( [url startAccessingSecurityScopedResource] ) > > Where did url come from? Presumably a bookmark, and since you expect it to be > a directory, it must be an application-scoped bookmark. > -startAccessingSecurityScopedResource will grant your app access to the > directory and all the files/folders etc. inside it (recursively). > >>> { >>> NSFileManager *defaultManager = [NSFileManager defaultManager]; >>> NSArray *contents = [defaultManager >>> contentsOfDirectoryAtPath:[url path] error:&error]; >>>[url stopAccessingSecurityScopedResource]; > > Access is counter-based, so assuming you haven’t got any other calls to > -startAccessingSecurityScopedResource for the same location on the go, this > line of code has just cut off access. > > Yes, you could first generate more bookmarks for each of the files inside the > directory, but that seems a weird thing to do for most use cases. Instead, > just keep access to the directory open until you’re finished with it. > >>> } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Design by contract and cocoa
On Jan 22, 2014, at 8:03 AM, jonat...@mugginsoft.com wrote: > I know there are some macros available, http://www.roard.com/contracts/, but > I haven’t experimented further as yet Interesting. I like the idea of dynamically creating a subclass that wraps the methods to be checked, but I don't like doing it with a bunch of macros. I wonder if there's a cleaner way to do it nowadays using newer Obj-C runtime features. (I'm assuming that code is old since the examples don't use any modern language features like properties.) —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Design by contract and cocoa
On 22 Jan 2014, at 17:50, Herman Chan wrote: > this seems to be the modernized version of it: > https://github.com/brynbellomy/ObjC-DesignByContract This is indeed a later implementation. It uses a metamacro approach as used in ReactiveCocoa. The code also has dependencies on another library that is not included as a submodule so a quick out of the box evaluation isn’t available. Neither this code nor the original look thread savvy - they both persist the contract state in a static variable. > > On 22 Jan 2014, at 12:37, Jens Alfke wrote: > >> On Jan 22, 2014, at 8:03 AM, jonat...@mugginsoft.com wrote: >> >>> I know there are some macros available, http://www.roard.com/contracts/, >>> but I haven’t experimented further as yet >> >> Interesting. I like the idea of dynamically creating a subclass that wraps >> the methods to be checked, but I don't like doing it with a bunch of macros. >> I wonder if there's a cleaner way to do it nowadays using newer Obj-C >> runtime features. (I'm assuming that code is old since the examples don't >> use any modern language features like properties.) The newer implementation eschews the dynamic subclassing approach. I am also not drawn to the metamacro approach. The old implementation uses -poseAsClass: and therefore is a dead duck on 64bits. A runtime approach as you suggest makes sense. KVO style subclassing comes to mind and associated objects could handle any state persistence. Jonathan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Priority MOC operations?
There's no way to get prioritized -performBlock: calls on an NSManagedObjectContext, is there? I have some operations enqueued with -performBlock: that must be serialized, and others that would be best carried out as soon as the current block finishes, but before any other enqueued blocks. -- Rick signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
UITableViewCell highlight color in iOS 7 (Settings app)
In my app, tapping on a UITableViewCell turns it gray. In the Settings app, it's blue. Is this just another instance of the Settings app using non-standard (and better-looking) UITableViews? -- Rick signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UITableViewCell highlight color in iOS 7 (Settings app)
On Jan 23, 2014, at 2:54 AM, Rick Mann wrote: > In my app, tapping on a UITableViewCell turns it gray. In the Settings app, > it's blue. Is this just another instance of the Settings app using > non-standard (and better-looking) UITableViews? > You can change it. Here is what I use in one of my apps: UIView *selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame]; selectedBackgroundView.backgroundColor = [UIColor colorWithRed:244.0/255.0 green:244.0/255.0 blue:244.0/255.0 alpha:1]; cell.selectedBackgroundView = selectedBackgroundView; -Nick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UITableViewCell highlight color in iOS 7 (Settings app)
On Jan 22, 2014, at 17:19 , Nick Petrov wrote: > > On Jan 23, 2014, at 2:54 AM, Rick Mann wrote: > >> In my app, tapping on a UITableViewCell turns it gray. In the Settings app, >> it's blue. Is this just another instance of the Settings app using >> non-standard (and better-looking) UITableViews? >> > > You can change it. Here is what I use in one of my apps: > > UIView *selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame]; > selectedBackgroundView.backgroundColor = [UIColor colorWithRed:244.0/255.0 > green:244.0/255.0 blue:244.0/255.0 alpha:1]; > cell.selectedBackgroundView = selectedBackgroundView; Right, thanks. I should've expanded my question. Is blue no longer a standard color? Why does IB still offer blue when in iOS 7 editing modes? Or is it a bug? -- Rick signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UITableViewCell highlight color in iOS 7 (Settings app)
On Jan 22, 2014, at 16:54 , Rick Mann wrote: > In my app, tapping on a UITableViewCell turns it gray. In the Settings app, > it's blue. Is this just another instance of the Settings app using > non-standard (and better-looking) UITableViews? Oddly, on my iPhone 4, it’s gray in Settings, but on my iPad Air, it’s blue in settings. According to the documentation, the old gray/blue settings shouldn’t be used any more — use “default” instead. I guess the old settings stay for source-code compatibility with old code. It’s *possible* that “default” means gray unless there’s some contextual tint setting somewhere, and then means the tint color. Or perhaps Settings is inadvertently using the old value. IDK why IB does what IB does (nobody does). So follow the documentation and use “default”. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
More UITableViewCell color woes
I have a static table view in a storyboard on iOS 7. They look correct in IB. One of the cells (the second) is a "Basic" cell, and when selected it draws in grey, and the text remains black. However, when not highlighted, the background color around the text is white, causing problems with the rest of the cell: http://cl.ly/image/0S3l3O3s0Q0D/Screenshot%202014.01.22%2017.40.49.png In IB, I can access the UILabel of the built-in "Basic" cell, and its background color is clear. Upon examining it in Reveal.app, its background color is #FF4D (white with a lot of transparency). It seems that iOS is changing the color, is this right? This crap is killing me right now. They need this fixed up ASAP for screenshots of our app. -- Rick signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Getting
I'm getting *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], but I'm not getting the message like this that you typically get (there's no message indicating what went wrong): 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted).' Every time a new thing is added to the list (as a result of scanning for BLE peripherals), I'm calling beginUpdate, doing an insert, add to the backing array, optionally a deletion (only on the first insert to get rid of a "none found" cell), and endUpdate. The assertion fires on the -endUpdate call at the fifth insert. So, this works most of the time. I can't figure out what's going on. Checking all the counts they seem fine. Any ideas what else may be going on? -- Rick signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Getting Assertion failure in -[UITableView _endCellAnimationsWithContext:]
(Let's try this with a subject!) I'm getting *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], but I'm not getting the message like this that you typically get (there's no message indicating what went wrong): 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted).' Every time a new thing is added to the list (as a result of scanning for BLE peripherals), I'm calling beginUpdate, doing an insert, add to the backing array, optionally a deletion (only on the first insert to get rid of a "none found" cell), and endUpdate. The assertion fires on the -endUpdate call at the fifth insert. So, this works most of the time. I can't figure out what's going on. Checking all the counts they seem fine. Any ideas what else may be going on? -- Rick signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com