Re: App store question regarding Big Sur
The behavior you describe has been the way the App Store has worked since the first major macOS update after its release; I wouldn’t expect that to change. Your users are likely *already* using Big Sur, at least some of them, on beta versions. Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org On Fri, Sep 18, 2020 at 7:43 AM Gabriel Zachmann via Cocoa-dev < cocoa-dev@lists.apple.com> wrote: > I've got an app on the Mac app store (MAS) which works under Catalina. > > My question is: when Big Sur becomes official, > will my app also show up in the MAS for people who's Mac runs under Big > Sur? > > I'm asking because I haven't had the time to test my app under Big Sur, > yet, > and I probably won't have time until early next year. > > Best regards, Gabriel > > ___ > > 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/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com > ___ 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
Reconnecting to a NetService after a stream error
Hi all, I’m writing an app that begins a NetService on tvOS and connects to it from iOS. I’m creating the service with a port number of 0 to get an automatic port and publishing with the .listenForConnections option. On the client (iOS) side, once I resolve an address for the service I use its getInputStream(_:outputStream:) method to get input and output streams set up. I create a background thread to handle callbacks on and schedule the streams on its RunLoop. What I’m noticing is that I get a lot of stream errors with this setup. I’m using JSONSerialization to write JSON objects to the stream and for the most part it works, but when I get these errors I’d like to reconnect. It seems like I can’t just call getInputStream(_:outputStream:) again on the resolved service, as doing so gives me all kinds of errors about a socket not being available. My next thing to try will be to rediscover the service, using its TXT data to make sure it’s the same one, re-resolve the address, and try again. I’m pretty new to Bonjour and there aren’t a whole lot of resources out there for how to handle stream errors. Am I on the right track? What kind of gotchas should I be aware of here (for instance, is there a hard number of clients that could conceivably connect to a NetService on an Apple TV)? Thanks in advance for any pointers! Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org ___ 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 elegance than a long if/else
I realized after sending that 100 won’t be correct, so you’ll need something like this: batteryIcon.image = UIImage(named: "\(min(10, (_myBatteryLevel % 10) + 1))") Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org On Fri, Mar 10, 2017 at 10:50 AM, Eric E. Dolecki wrote: > Thank you! > > On Fri, Mar 10, 2017 at 10:48 AM Jeff Kelley > wrote: > >> Something like this should work: >> >> batteryIcon.image = UIImage(named: "\((_myBatteryLevel % 10) + 1)") >> >> >> Jeff Kelley >> >> slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | >> jeffkelley.org >> >> On Fri, Mar 10, 2017 at 10:41 AM, Eric E. Dolecki >> wrote: >> >> I have this super simple code, but I'd like to whittle it down to >> something >> a lot smaller - basically looking for multiples of 10 (100-0) for a value. >> I need coffee, what's a great way to do this in Swift 3? >> >> if _myBatteryLevel >= 90 { >> batteryIcon.image = UIImage(named: "10") >> } else if _myBatteryLevel >= 80 { >> batteryIcon.image = UIImage(named: "9") >> } else if _myBatteryLevel >= 70 { >> batteryIcon.image = UIImage(named: "8") >> } else if _myBatteryLevel >= 60 { >> batteryIcon.image = UIImage(named: "7") >> } else if _myBatteryLevel >= 50 { >> batteryIcon.image = UIImage(named: "6") >> } else if _myBatteryLevel >= 40 { >> batteryIcon.image = UIImage(named: "5") >> } else if _myBatteryLevel >= 30 { >> batteryIcon.image = UIImage(named: "4") >> } else if _myBatteryLevel >= 20 { >> batteryIcon.image = UIImage(named: "3") >> } else if _myBatteryLevel >= 10 { >> batteryIcon.image = UIImage(named: "2") >> } else if _myBatteryLevel >= 0 { >> batteryIcon.image = UIImage(named: "1") >> } >> >> Thanks for thinking about my lame code. >> >> ___ >> >> 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/slaunchaman%40gmail.com >> >> This email sent to slauncha...@gmail.com >> >> >> ___ 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 elegance than a long if/else
Something like this should work: batteryIcon.image = UIImage(named: "\((_myBatteryLevel % 10) + 1)") Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org On Fri, Mar 10, 2017 at 10:41 AM, Eric E. Dolecki wrote: > I have this super simple code, but I'd like to whittle it down to something > a lot smaller - basically looking for multiples of 10 (100-0) for a value. > I need coffee, what's a great way to do this in Swift 3? > > if _myBatteryLevel >= 90 { > batteryIcon.image = UIImage(named: "10") > } else if _myBatteryLevel >= 80 { > batteryIcon.image = UIImage(named: "9") > } else if _myBatteryLevel >= 70 { > batteryIcon.image = UIImage(named: "8") > } else if _myBatteryLevel >= 60 { > batteryIcon.image = UIImage(named: "7") > } else if _myBatteryLevel >= 50 { > batteryIcon.image = UIImage(named: "6") > } else if _myBatteryLevel >= 40 { > batteryIcon.image = UIImage(named: "5") > } else if _myBatteryLevel >= 30 { > batteryIcon.image = UIImage(named: "4") > } else if _myBatteryLevel >= 20 { > batteryIcon.image = UIImage(named: "3") > } else if _myBatteryLevel >= 10 { > batteryIcon.image = UIImage(named: "2") > } else if _myBatteryLevel >= 0 { > batteryIcon.image = UIImage(named: "1") > } > > Thanks for thinking about my lame code. > ___ > > 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/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com > ___ 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: WatchOS3 layering?
Hi Eric, This sounds achievable. You can embed interface objects inside of a WKInterfaceGroup, and that group can have a background image. So you’d put the group in with your background image, and then inside of it would be the semicircle image. Does that sound like it would work? Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org On Thu, Jan 26, 2017 at 10:55 PM, Eric Dolecki wrote: > I have a quick question. > I've been asked to make a companion watch app and have been given a sketch > file for the design. In the design in the center is an image of a product. > On top and larger is an image that will be hooked up via sequence to the > digital crown - a semicircle progress thing. > So it seems like two images atop one another. Is this possible? For iOS > it's a no brainier. I've dabbled in watch development but it's been a long > time. > Eric > > Get Outlook for iOS > ___ > > 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/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com ___ 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: Make WatchKit app show local notification
The recommended approach here (I think) is to show the notification on whichever device the user is using. Are you implementing any of the UserNotification framework pieces on the phone? Would it work for your purposes if the alert sometimes appeared there? Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org <http://jeffkelley.org/> > On Nov 11, 2016, at 7:13 AM, Charles Jenkins wrote: > > Thanks, Jeff! Lordy be, the only thing I want is a sound and prominent haptic > when the countdown reaches zero. Is there no foolproof way to achieve that? > Everything I’ve tried seems to only work in certain cases. ___ 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: Make WatchKit app show local notification
Hi Charles, Your code looks good to me. One thing to look at is if the iPhone is unlocked. By default, the watch will only show notifications if it’s on your wrist and unlocked, and your iPhone is locked. If you’re using the phone, it won’t show notifications on your wrist. If you ensure those conditions, is it better? Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org <http://jeffkelley.org/> > On Nov 10, 2016, at 8:50 PM, Charles Jenkins wrote: > > I’m trying to write an app that basically serves as a countdown timer. I’ve > learned that the WKInterfaceTimer object doesn’t really do anything but > draw the countdown on the screen. The documentation suggests pairing it > with an NSTimer in order to be able to do something when the timer expires. > > I think the NSTimer approach is pretty worthless on the watch, because if > the timer counts down for a long time, the app may be suspended or killed. > And even if it only goes to background, when the timer expires, you’re not > allowed to play haptics to alert the user. (These are the first things I > tried, to no avail.) > > So instead of using a timer, I schedule a notification. The problem is, I > can’t seem to make sure the notification’s alert is displayed when it > arrives! > > Below is the top part of my ExtensionDelegate file. When the notification > arrives, I get the message on my console saying we’re asking the system to > present it, but nothing happens. > > What the heck else do I need to do to make sure notifications aren’t > suppressed by the watch? > > import WatchKit > import UserNotifications > > class ExtensionDelegate: NSObject, WKExtensionDelegate, > UNUserNotificationCenterDelegate { > > func applicationDidFinishLaunching() { >let nc = UNUserNotificationCenter.current() >nc.delegate = self >nc.requestAuthorization( options: [.alert, .sound] ) { > ( accepted, error ) in > if !accepted { >print("Notification access denied.") > } >} > } > > func userNotificationCenter( >_ center: UNUserNotificationCenter, >willPresent notification: UNNotification, >withCompletionHandler completionHandler: @escaping ( > UNNotificationPresentationOptions ) -> Void > ) { >print( "Received alert--asking system to present it" ) >completionHandler( [ .alert, .sound ] ) > } > > > } > > -- > > Charles > ___ > > 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/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com ___ 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: Vertical orientation of UISlider
Reminds me of the old days before UICollectionView, where you could have table view cells scroll horizontally by embedding a rotated table view in each cell, then rotating the child table view’s cells in the opposite direction. Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org <http://jeffkelley.org/> > On Jul 20, 2016, at 12:02 PM, Doug Hill wrote: > > A rotate transform will work fine if you don't have any customizations. For > example, a thumb, min/max image will end up being rotated as well, so you'll > need to transform those too. > > Doug > > On Jul 20, 2016, at 11:55 AM, Jeff Kelley wrote: >> >> Hi Carl, >> >> Have you tried applying a transform to the slider? A simple rotation >> should do the trick. >> >> >> Jeff Kelley >> >> slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | >> jeffkelley.org <http://jeffkelley.org/> >>> On Jul 20, 2016, at 11:48 AM, Carl Hoefs >>> wrote: >>> >>> iOS 9 >>> >>> Is there a way to change the orientation of a UISlider to vertical instead >>> of horizontal? >>> >>> -Carl >> ___ > ___ 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: Vertical orientation of UISlider
Hi Carl, Have you tried applying a transform to the slider? A simple rotation should do the trick. Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org <http://jeffkelley.org/> > On Jul 20, 2016, at 11:48 AM, Carl Hoefs > wrote: > > iOS 9 > > Is there a way to change the orientation of a UISlider to vertical instead of > horizontal? > > -Carl ___ 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: Air Drop-style sharing between instances of my app?
That sounds like the perfect use case for using the MultipeerConnectivity framework. At a lower level, you could use Bonjour (though that requires the devices to be on the same network). Jeff Kelley > On Apr 20, 2016, at 9:33 PM, Rick Mann wrote: > > Is there a way to do Air Drop-style sharing between two instances of my app > (running on separate devices near each other)? It seems I can AirDrop to any > other device, but I want to restrict it to devices that have my app installed. > > Our app gathers app-specific data. It can be beneficial to the user to have > more than one person using a device gathering data, and then have all the > additional users transfer the data they gathered from their device to one > "main" device. > > Would Peer-to-peer connectivity be a way to accomplish this? The idea would > be for users to browse for other nearby devices running the app, and then > offer data, and have the other app pop up UI authorizing the transfer. > > Thanks, > > -- > Rick Mann > rm...@latencyzero.com > > > > ___ > > 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/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com ___ 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: calendar & repeating events api
I would start by looking at EKRecurrenceRule <https://developer.apple.com/library/ios/documentation/EventKit/Reference/EKRecurrenceRuleClassRef/index.html>. Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org <http://jeffkelley.org/> > On Feb 16, 2016, at 9:34 PM, Eric Gorr wrote: > > When setting up a repeating event in Apple’s Calendar application, there is a > lot of flexibility. For example, I can specify that an event repeats every > month on the 5th Saturday. Of course, not every month has a fifth saturday, > so for that month there is no event. > > What I am wondering is if there is direct api support for doing these date > calculations…can I supply a set of parameters to a function and ask what the > next 5th saturday of the month is? > > I can, of course, implement a naive algorithm which simply iterates through > each day of the month, checks to see if it is the 5th Saturday encountered > and return that date, but I am hoping I would not need to write something so > tedious and prone to error. If there is a 3rd party library that would > provide such support, I would be interested in learning about it as well. > > Thank you. ___ 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: Subclassing/Override question
Hi Dave, For myClassA, you will always have to cast the return value to myClassB if you know that’s what will be returned. For a great blog post on the subject, I give you Mike Ash: https://mikeash.com/pyblog/friday-qa-2015-11-20-covariance-and-contravariance.html Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org <http://jeffkelley.org/> > On Jan 4, 2016, at 11:24 AM, Dave wrote: > > Hi, > > In Objective-C, is it possible to override a property and have it return a > different type to the base class? > > I have a base class with the following property defined: > > @property (nonatomic,retain) ClassA* propA; > > and the following getter: > > > -(ClassA*) propA > { > return someValueOfClassA; > } > > > I’d like to override this in my subclass, as so: > > -(ClassB*) propA > { > ClassA* myClassA; > ClassB* myClassB; > > myClassA = super.propA; > myClassB = [[ClassB alloc] initWithClassA:myClassA]; //ClassB is a subclass > of Class A > > return myClassB; > } > > I can do this ok, but when I access the property: > > // myClassA is already setup OK > ClassB* myClassB; > > myClassB = myClassA.propA;//Warning on this line saying > return type is not ClassB > > and I have to coerce the value to be ClassB to get rid of the warning. Is > there any way to avoid this? > > Thanks a lot > Dave ___ 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: Common Date between Swift and ObjC
Gerriet, You should be able to make a constant variable, not a preprocessor definition, and import the file that declares it in your project’s bridging header. Something like this: in Constants.h: extern const NSInteger kParameterA; in Constants.m: const NSInteger kParameterA = 17; Then, in your bridging header, you’d import Constants.h. Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org On Tue, Aug 12, 2014 at 1:47 PM, Gerriet M. Denkmann wrote: > In ObjC I used to do: > CommonDefines.h > #define PARAMETER_A 17 > and then import CommonDefines.h into all files which have to know this > parameter. > > But how do I make a Swift file and an ObjC file both aware of the value of > PARAMETER_A? > > Keeping both in sync is rather error prone; I much rather have the value > in only one place (like my CommonDefines.h). > > Gerriet. ___ 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: iOS screen physical size (or px density)
This distinction between iPad-sized controls and iPhone-sized controls is confusing. On either platform, the guideline has always been to prefer 44 pt by 44 pt touch targets. The iPad having a lower pixel density than the iPhone (when comparing screens of the same scale) is balanced by users holding it further from their face. If you find that your iPad UI is too small on the iPad mini, then it was likely too small to begin with on the iPad. Jeff Kelley slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org On Tue, Nov 26, 2013 at 12:00 PM, Maxthon Chan wrote: > I’d like to say just get rid of the old iPad-sized control design and > embrace iPhone-sized controls with iPad-styled layout - they will look good > on both iPad mini and iPhone since they have the same pixel (point) density > and when regular iPads are used, despite being sub-optimal, the UX will not > be shabby as well. > > On Nov 26, 2013, at 23:13, Roland King wrote: > > > "Design for mini" I agree with. I never had a mini before last weekend > and didn't realise what looked great on a full-size didn't work scaled down > but what looked great on a mini still looked ok scaled up. I'm going to be > just as conscious of mini vs normal as I have been iPhone vs iPad paradigm > from now on. > > > > On 26 Nov, 2013, at 10:54 pm, Igor Elland wrote: > > > >> > >> On 26 Nov 2013, at 15:51, Roland King wrote: > >> > >>> Until then, re-designing that one screen for the mini and letting it > scale up for the normal iPad worked very well, so perhaps Apple were right > in the first place, one iPad size does fit all, just not the size I started > with. > >> > >> I think following the HIG specifications for size really helps here, > when there’s nothing smaller than the smallest suggested sizes, they do > translate fairly well. But if you have really busy UIs with smaller > controls than the HIG recommends, than designing “for the Mini first” > should help prevent and elucidate such cases. > >> > >> 👍 > > > > ___ > > 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/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com > ___ 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: NSMethodSignature throws an exception encoding GLKMatrix4
Sorry to bring up an old topic, but I’m still running into this and I’ve reported it as a bug (rdar://14931876). Say you have this method: - (GLKMatrix4)identityReturningMethod { return GLKMatrix4Identity; } Now, in another method in the same class, you try to make a signature for that selector: [[self class] instanceMethodSignatureForSelector:@selector (identityReturningMethod)]; This will crash with the exception in my previous post. Am I correct that this is a bug in +[NSMethodSignature signatureWithObjCTypes:]? Jeff Kelley On Wed, Aug 21, 2013 at 12:51 PM, Marcel Weiher wrote: > > On Aug 21, 2013, at 17:24 , Jeff Kelley wrote: > > > *** Terminating app due to uncaught exception 'NSInvalidArgumentException', > > reason: '+[NSMethodSignature signatureWithObjCTypes:]: unsupported type > encoding spec '(' in '(_GLKMatrix4={?=}[16f])8@12'' > > > > I’m not too familiar with NSMethodSignature; is this something I could get > around fairly easily? My current approach is going to be to box GLKMatrix4 > into an object (probably NSValue) and use that instead, but I would be > interested to be able to fix it in Kiwi if possible. > > > It looks like it doesn’t like the structure name, the following is fine: > > [NSMethodSignature signatureWithObjCTypes:"{?=}[16f]8@12”] > > Whereas the following is not: > > [NSMethodSignature > signatureWithObjCTypes:"(_GLKMatrix4={?=}[16f])8@12”] > > Cheers, > > Marcel > > ___ 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: Threadsafe copy of objective c object
Ken is, of course, correct. This is what I get for writing it in my mail client. You’ll want to use dispatch_sync() for reads and dispatch_barrier_async() for writes. Jeff Kelley On Tue, Sep 3, 2013 at 2:30 PM, Ken Thomases wrote: > On Sep 3, 2013, at 9:26 AM, Jeff Kelley wrote: > > > You could use a dedicated dispatch queue for all property access and use > > dispatch barriers to restrict access to the queue for writes, while still > > allowing simultaneous reads. > > > > In -copy: > > > > - (id)copy > > { > > __block __typeof(self) copy; > > > > dispatch_async(self.propertyQueue, ^{ > > You can't use dispatch_async() for this. It has to be synchronous, since > you're returning the value that's going to be set. > > > copy = [[[self class] alloc] init]; > > // Copy properties here > > }); > > > > return copy; > > } > > > > This assumes a property called propertyQueue: > > > > @property (readonly, nonatomic) dispatch_queue_t propertyQueue; > > > > - (dispatch_queue_t)propertyQueue > > { > > if (!_propertyQueue) { > > _propertyQueue = dispatch_queue_create("queue name here", > > DISPATCH_QUEUE_CONCURRENT); > > } > > > > return _propertyQueue; > > } > > > > > > In your property getters: > > > > - (int)count > > { > > __block int count; > > > > dispatch_async(self.propertyQueue, ^{ > > Same here. > > > count = _count; > > }); > > > > return count; > > } > > > > > > And finally, in your property *setters*: > > > > - (void)setCount:(int)count > > { > > dispatch_barrier_async(self.propertyQueue, ^{ > > _count = count; > > }); > > } > > Regards, > Ken > > ___ 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: Threadsafe copy of objective c object
You could use a dedicated dispatch queue for all property access and use dispatch barriers to restrict access to the queue for writes, while still allowing simultaneous reads. In -copy: - (id)copy { __block __typeof(self) copy; dispatch_async(self.propertyQueue, ^{ copy = [[[self class] alloc] init]; // Copy properties here }); return copy; } This assumes a property called propertyQueue: @property (readonly, nonatomic) dispatch_queue_t propertyQueue; - (dispatch_queue_t)propertyQueue { if (!_propertyQueue) { _propertyQueue = dispatch_queue_create("queue name here", DISPATCH_QUEUE_CONCURRENT); } return _propertyQueue; } In your property getters: - (int)count { __block int count; dispatch_async(self.propertyQueue, ^{ count = _count; }); return count; } And finally, in your property *setters*: - (void)setCount:(int)count { dispatch_barrier_async(self.propertyQueue, ^{ _count = count; }); } Hope this helps! (Note: all code was typed in the e-mail, so may not compile.) Jeff Kelley On Tue, Sep 3, 2013 at 9:34 AM, Jonathan Taylor < jonathan.tay...@glasgow.ac.uk> wrote: > Ah. In my original email I didn't explain *why* it is that "ideally I > would like to make the copy on a thread other than the main thread". The > algorithm is doing real-time video processing, and I very much want to > avoid holding up anything in that code path by synchronizing with the main > queue. Past experience has shown that that does lead to glitches I am keen > to avoid. So, while I'm a big fan of such constructions, I'm deliberately > trying to avoid that here. > > Serializing access to MyParameters will work, it's just a shame that there > isn't such a tidy way of achieving that... > > > On 3 Sep 2013, at 14:18, Robert Vojta wrote: > > > Then this should be enough ... > > > > - (MyParameters *)copyParameters { > > __block MyParameters *parameters; > > dispatch_sync( dispatch_get_main_queue(), ^{ > > parameters = [myObjectHoldingParameters.parameters copy]; > > }); > > return parameters; > > } > > > > ... if all your parameters object properties are set on the main thread > only. > > > > > ___ > > 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/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com > ___ 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: frame puzzle
If any of appDelegate, appDelegate.buttonController, or appDelegate.buttonController.rotationControl return nil, then the value of appDelegate.buttonController.rotationControl.frame will be a zeroed-out struct. Jeff Kelley On Thu, Aug 22, 2013 at 4:05 PM, David Rowland wrote: > > > CGRect tframe = CGRectMake(12, 12, 100, 100); > [appDelegate.buttonController.rotationControl setFrame:tframe]; > CGRect qframe = appDelegate.buttonController.rotationControl.frame; > > > buttonController is a UIViewController, rotationControl is a UIControl. > When this is executed qframe is reported as (0, 0, 0, 0). Does anyone see > what is wrong? > > thanks, > > David > > > ___ > > 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/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com ___ 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
NSMethodSignature throws an exception encoding GLKMatrix4
I’ve been trying to TDD an app that uses GLKit using the Kiwi test framework. One of the methods I’m stubbing returns a GLKMatrix4. I stub it like this: PhysicsManager *mockManager = [PhysicsManager mock]; > [mockManager stub:@selector(physicsTransformForObject:) > andReturn:theValue(GLKMatrix4Identity)]; When that code executes, it tries to encode the type of GLKMatrix4 and I get this error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', > reason: '+[NSMethodSignature signatureWithObjCTypes:]: unsupported type > encoding spec '(' in '(_GLKMatrix4={?=}[16f])8@12'' I’m not too familiar with NSMethodSignature; is this something I could get around fairly easily? My current approach is going to be to box GLKMatrix4 into an object (probably NSValue) and use that instead, but I would be interested to be able to fix it in Kiwi if possible. Jeff Kelley ___ 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: APN and various apps determining each other present on a device?
It’s relatively simple: App A registers for a URL scheme, let’s say AppA://. App B asks the system if it knows how to handle AppA:// links. Jeff Kelley On Oct 3, 2012, at 10:36 PM, William Squires wrote: > Let's say a company, IMakeGamesCo, has several games in the App Store (iOS). > Is there an API for determining (from one app) if another app from the same > developer is installed? I'm guessing "yes" because I've seen several apps > that can do this; most of them by PocketGems (example: Tap Paradise Cove can > tell if you installed Tap Campus Life, and give you a reward for completing a > quest in Paradise Cove if you complete some other quest in Campus Life. Or is > this just all server-side? Is this part of APN (push notifications)? ___ 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: False positive on writeToURL:atomically:encoding:error: ?
Martin, Instead of inspecting the value of error, you should be inspecting the return value of writeToURL:atomically:encoding:error:. Only if that returns NO should you be inspecting the value of error which, as you’ve seen, may be non-nil on success. You can see an example here: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Strings/Articles/readingFiles.html#//apple_ref/doc/uid/TP40003459-SW5 Jeff Kelley On Jun 23, 2012, at 1:50 PM, Martin Hewitson wrote: > Dear list, > > I have an interesting bug report from a user of an app of mine. The app > manages files and allows the user to edit them. When they save the project > each file is saved to disk (if necessary). They are experiencing what appears > to be a false positive of writeToURL:atomically:encoding:error:. The file > actually does save, but the error comes back non-nil and when presented says: > > "You don’t have permission to save the file “XXX” in the folder “YYY”. > > The piece of code I use is > > NSError *error = nil; > [content writeToURL:aURL atomically:YES encoding:encoding error:&error]; > if (error) { >[NSApp presentError:error]; >return NO; > } > > By giving the user a debug version of the app with lots of NSLog statements, > we narrowed it down to the above code. So even though the file is saved, > 'error' comes back non-nil. > > Has anyone seen such behaviour before, or does anyone have any idea how to > further investigate this? > > Best wishes, > > Martin > > > > > ___ > > 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/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com ___ 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: How to throttle rate of NSInputStream?
It's always felt like a hack to me, but this will run the run loop for a short time and return: [[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]]; Though in your case, if the first thing it does is process your input stream, that doesn't help. Jeff Kelley On Mar 26, 2012, at 7:13 PM, Jens Alfke wrote: > [I posted this to macnetworkprog earlier today, but 3 hours later it hasn’t > shown up yet, so I’m trying here too.] > > I’m using an async NSInputStream to read from a TCP socket. Given a good > connection, the data comes in faster than an iOS device can parse it (it’s a > stream of small JSON docs, one per line.) I’m performance-tuning my code, and > finding that NSInputStream is shoving all of the data down my throat at once, > without giving the runloop a chance to process any other input sources. This > means that my thread is blocked, and other tasks scheduled on it don’t get a > chance to run, until I’ve read the whole feed, which takes over a minute. > (And there’s also the fact that CFNetwork must be buffering megabytes of data > from the socket that my code hasn’t read yet.) > > This seems to hinge on the way the stream calls my event handler. When I get > the NSStreamEventHasBytesAvailable, I only read 8k bytes of data at a time, > then return. What seems to happen is that, if that didn’t consume all of the > available data, the stream will keep sending me the event in a tight loop > without exiting back to the runloop in between. > > What can I do about this? Ideally I’d like the stream to hold off on reading > more from the socket until my code finishes processing the buffer. As a > second choice, I’d like it to at least return the runloop more often so my > other tasks get time to run. > > —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: ARC and blocks
On Jan 26, 2012, at 10:45 PM, Roland King wrote: > > On Jan 27, 2012, at 10:04 AM, Marco Tabini wrote: > >> On 2012-01-26, at 6:09 PM, Jeff Kelley wrote: >> >>> Without ARC, you would use __block to prevent the block from retaining the >>> object and causing the retain cycle. With ARC, however, the object is >>> retained when you put it into the variable, so to avoid a retain cycle, you >>> have to declare it like so: >>> >>> __unsafe_unretained __block MyViewController *myController = … >>> >>> It looks awful, yes, but without the first piece we were having extreme >>> memory leaks. >> >> Maybe I'm reading this wrong, but I think this might be a bit too unsafe. If >> you declare something as __unsafe_unretained, ARC won't try to track the >> variable through its lifetime, so if for some reason that variable is >> deallocated and then your block gets called, your app will crash. The OP's >> code feels a bit safer to me: it retains the variable strongly, then Nils it >> at the end of the block to force a release. There's no retain cycle or >> memory leak, and the __block variable is guaranteed to stick around until >> your block is done with it. >> > > Yes - that __unsafe_unretained pattern is in the transition guide, but it's > not recommended and seems to be there more for illustration of what pre-ARC > code was equivalent to. Just setting the __block variable nil will work fine > under ARC and pre-ARC runtimes so, unless the code in that block is really > complex and it's hard to set the block variable nil in all relevant places, > I'd definitely use the OPs code (which is what the transition guide seems to > recommend also). I agree, but in the case I ran into, I passed more than one block to the object, which would then call one of them depending on the outcome of its operations. Since not every block would be called, those temporary retain cycles would last forever. I'm also using ARC and targeting iOS 4.3. If you're only setting one block and you know it's going to be called, setting it to nil ought to do the trick. Jeff Kelley ___ 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: ARC and blocks
Without ARC, you would use __block to prevent the block from retaining the object and causing the retain cycle. With ARC, however, the object is retained when you put it into the variable, so to avoid a retain cycle, you have to declare it like so: __unsafe_unretained __block MyViewController *myController = … It looks awful, yes, but without the first piece we were having extreme memory leaks. Jeff Kelley On Jan 26, 2012, at 5:34 PM, David Duncan wrote: > On Jan 26, 2012, at 1:51 PM, Jan E. Schotsman wrote: > >> Hello, >> >> This code is given in the "Transitioning to ARC Release Notes" as an example >> of accomodating blocks in an ARC environment: >> >> __block MyViewController *myController = [[MyViewController alloc] init…]; >> // ... >> myController.completionHandler = ^(NSInteger result) { >> [myController dismissViewControllerAnimated:YES completion:nil]; >> myController = nil; >> }; >> >> Supposedly this avoids a retain cycle. But where is the cycle? At least two >> objects are needed for a cycle. What is the second one? >> Excuse me if I'm being dumb. > > > myController retains/copies the block. Then the block retains myController > (under ARC __block variables are strong references, so they get retained). > Thus you are left with myController retains the block which retains > myController. > -- > David Duncan ___ 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: capturing self is likely to lead to a retain cycle ..
ARC doesn’t know in the context of that method what will happen to the block. Each method lives in a vacuum with retain counts being consistent at the beginning and end. So, even though you know that the block will be released, that’s not clear in the context of the method. I would recommend the approach of a weak reference to self. Jeff Kelley On Sat, Nov 12, 2011 at 3:14 AM, Roland King wrote: > I have a UIViewController which is presented modally, it has a textfield > which allows editing and a model object, call it foo, on which it can > attempt to set the 'topicName' property. Because I'm dealing with > UIDocument(s) and trying to be nicely iCloud compatible and the topic name > change does require a background call, the setTopicName: method cannot > directly return YES or NO, it has a completionHandler which runs after the > operation is attempted (and on the main thread). I'm using that completion > handler to either pop up an alert sheet saying it failed, or call the > onCancel: method of myself to dismiss the modal window. > > With the code below I'm getting a warning "Automatic Reference Counting > Issue: Capturing 'self' strongly in this block is likely to lead to a > retain cycle", but I don't see why. I understand that 'self' is retained by > the block, but after the block runs, it should be released again. I've > re-read the ARC guide and understand why, if you set a block as a property > of yourself and that block uses self, it can cause a retain cycle, but I'm > not setting this block as a property and I don't see how, for an anonymous > block which is passed down the call chain and run, there would be a retain > cycle. > > Am I missing the blindingly obvious, or is ARC just being very cautious > about ANY block retaining self and suggesting I use another pattern? I can, > I can easily set up a weak reference to myself just before the block and > use it .. I just want to understand why. > > > -(BOOL)textFieldShouldReturn:(UITextField*)textField > { >[ foo setTopicName:[ textField text ] > completionHandler:^(BOOL)success{ > >if( !success ) >{ >// present an alert sheet >} >else >{ >// onCancel is also the callback from the 'cancel' > button and dismissed this modally presented viewcontroller >[ self onCancel:nil ]; // <-- ARC not too happy > with this >} >} ]; > }___ > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com > ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Allocating too much memory kills my App rather than returning NULL
On Wed, Nov 9, 2011 at 3:08 AM, Don Quixote de la Mancha < quix...@dulcineatech.com> wrote: > > While the iOS and Mac OS X do have a better security track record than > Windows does, I'm quite certain that's because "The Scene" has been > focussing on Windows due to its greater numbers. With Apple's > increasing financial success, malware such as Mac Defender is starting > to crop up. > Mac Defender was a scam app that the user had to download and run. That’s barely malware, and can by definition happen on any platform that allows users to run downloaded code. Code Red, on the other hand, could infect a server running IIS without user interaction. They really could not be more different from a security perspective. > Apple's security update to fix the Mac Defender exploit was a gigabyte > download - compressed! That suggests that whatever holes Apple > plugged were all over creation. > Or that the files involved were big. Apple’s patches aren’t binary diffs, so if you patch a 200MB file with a one-line change, that whole file is still included in the update package. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: C struct and __unsafe_unretained
The recommendation is to replace the struct with a class. So you would replace x with a class that might look like this: > @interface ReplaceX : NSObject > > @property (copy) NSString *label; > @property int value; > > @end This aside, you should be OK using __unsafe_unretained in an App Store application as long as you’re only using constant strings (which won’t be released). Jeff Kelley On Oct 30, 2011, at 1:32 PM, James Merkel wrote: > The document on ARC talks about problematic C structs like: > > struct x { NSString *S; int X; } StaticArray[] = { > @"foo", 42, > @"bar, 97, > ... > }; > > I use that pattern quite a bit in my code and haven't had any problems with > it. These are basically constant strings that never change. > > With ARC, the compiler wants me to change the code to: > > struct x { __unsafe_unretained NSString *S; int X; } > > Aside from this looking really ugly, will the App store accept this in an > application? > > The document on ARC says in order to do this task correctly, the code should > be changed to a class. Ok, what class are they talking about? > > I don't see how the collection classes like NSDictionary or NSArray support > this. Do they mean create your own collection class to do this? > > Thanks for any insight on this. > > Jim Merkel ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Can I jsut use @2x images without supplying a @1x image?
Can you? Sure. Keep in mind, though, that the iPhones and iPod Touches without Retina Displays also have less memory, so loading double-scaled images will cause your app to use much more memory than necessary. This may not affect your application, but it may cause other applications to be unloaded from memory earlier, causing your users’ experience to suffer. So to be a good iOS citizen, you ought to include the 1x versions as well. Jeff Kelley On Oct 21, 2011, at 3:42 PM, David Hoerl wrote: > I noticed by accident that everything seems to work just fine if I supply a > im...@2x.png in my iOS code, reference as normal [UIImage > imageNamed:@"image.png"], even if I'm targetting code at a non-retina iPhone. > > So, is this really acceptable? In virtually every image I have, the 1x image > is just a scaled down 2x image. By dropping the 1x images I can greatly > reduce the number of images stuffed into my app. > > Thanks, > > David ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Core Data Concurrency Issues
I’m having some issues with concurrency with Core Data. I create an object that has a to-many relationship with another object (which in turn has a to-one reciprocal relationship with the first object), then dispatch_async onto a private queue. In that queue, I use a separate managed object context, which I’ve created earlier and only use within that queue. Here’s a snippet: ParentObject *parent = [NSEntityDescription insertNewObjectForEntityName:@"ParentObject"] inContext:[self moc]]; NSManagedObjectID *objectID = [parent objectID]; dispatch_async(dedicatedQueue, ^{ // Note: childContext is an NSManagedObjectContext that has been created earlier and is only used within this queue. ParentObject *parent = [childContext objectWithID:userID]; for (NSDictionary *jsonDict in allChildDicts) { ChildObject *child = [NSEntityDescription insertNewObjectForEntityName:@"ChildObject"] inContext:childContext]; [parent addChildObject:child]; } }); If I try to save the context within the dedicated queue, I get validation errors on the child objects with the text “Dangling reference to an invalid object.” It appears to work correctly if I create the parent object within the dedicated child queue. So, what is the proper way to create these objects on the main queue and then update them in the background? Thanks in advance. Jeff Kelley ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: ARC and Singletons
Traditionally, I used the standard +sharedInstance type of singleton, but I returned it autoreleased and in its dealloc method, set the sharedInstance variable to nil if it was the shared instance: > - (void)dealloc > { > if (self == sharedInstance) { > sharedInstance = nil; > } > > // Clean up ivars here > > [super dealloc]; > } When I create a singleton I did it like this: > + (MySingletonClass *)sharedInstance > { > if (sharedInstance == nil) { > sharedInstance = [[[self alloc] init] autorelease]; > } > > return sharedInstance; > } That had the advantage of allowing the singleton to be released and free up its memory if no longer needed, but I think the tradeoff in code simplicity with ARC will be worth the handful of pointers that will stick around in memory with my singleton staying alive. There were also obviously concurrency concerns. If I were retaining something large, such as graphics, in the singleton, I guess I’d have to respond to memory warnings appropriately and kill resources at that time. Thanks for the feedback, guys. Jeff Kelley On Aug 1, 2011, at 1:52 PM, David Duncan wrote: > On Aug 1, 2011, at 10:12 AM, Kyle Sluder wrote: > >> On Mon, Aug 1, 2011 at 9:05 AM, Dave Zarzycki wrote: >>> The simplest and most ARC friendly way to implement the singleton pattern >>> is to switch from instance methods to class methods – because the class >>> itself is by definition a singleton. In other words: >> >> Eek, this might be conceptually simple but it's a ton of work and >> giant step backwards in API design. Remember when -[NSFileManager >> alloc] became useful in 10.5? > > > There's nothing wrong with using the +sharedInstance approach either, just > remove all the shenanigans that were defined to ensure that there was only > one instance. In the majority of cases it was likely overkill and potentially > masking memory management bugs. > -- > David Duncan ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: ARC and Singletons
Interesting. Your +setFoo: example, I’m assuming, sets a global int. What about objects? I’m assuming that if I declare a global NSArray pointer like so: NSArray *foo = nil; and then have a +setFoo:(NSArray *)array method, that calling it with nil will be sufficient to clean up the array (that is, the ARC code will release the current array)? Jeff Kelley On Mon, Aug 1, 2011 at 12:05 PM, Dave Zarzycki wrote: > The simplest and most ARC friendly way to implement the singleton pattern > is to switch from instance methods to class methods – because the class > itself is by definition a singleton. In other words: > >+ (MyClass *)sharedInstance; >// and maybe override alloc/retain/release to enforce the singleton > pattern >- (int)foo; >- (void)setFoo:(int)val; > > …becomes simply: > >+ (int)foo; >+ (void)setFoo:(int)val; > > davez > > > On Aug 1, 2011, at 8:48 AM, Jeff Kelley wrote: > > > Is there a new recommended way to implement a singleton with ARC? I > remember > > hearing something about it, but I’m not sure what it was. > > > > Jeff Kelley > ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
ARC and Singletons
Is there a new recommended way to implement a singleton with ARC? I remember hearing something about it, but I’m not sure what it was. Jeff Kelley ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Question about NSThread
You *can*, but there is a limit to the number of threads you can create, and even if you’re under the limit, you’ll likely be pegging the CPU in an inefficient way. You would be better served using GCD and creating a dispatch queue, then scheduling the task on that queue (or just using a global queue). Jeff Kelley On Thu, Jul 14, 2011 at 10:08 AM, Eric E. Dolecki wrote: > I haven't done much research, but if I have a method that does a lot of > looping, can I just safely bust this off (fire and forget)? > > [NSThread detachNewThreadSelector:@selector(generateBigData) toTarget:self > withObject:nil]; > ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS: String Drawing
To echo Graham’s point, you can also use the CALayer of the label and modify its properties to get a more customized appearance. You’ve got shadowColor, shadowOffset, shadowOpacity, shadowPath, and shadowRadius. Between those properties and the label’s built-in shadow support, there’s a lot of customization to be had. Jeff Kelley On Tue, Jul 12, 2011 at 6:22 AM, Graham Cox wrote: > AFAIK, you don't have to subclass UILabel - it has a shadowColor/offset > property that you can set as you wish, and it should all "just work". Sure, > the default values are sometimes a bit questionable, but all you need to do > is to set those shadow properties in IB or in code. > > You're doing way too much work, and breaking something in the process. I > don't see anything in your code that adds anything to what you can do with > the view's standard properties. Also, I found that things such as shadow > blur radius aren't necessarily well supported in iOS, which probably doesn't > have the processing power to do that very well - even on Mac shadows kill > performance. > > --Graham > > > On 12/07/2011, at 4:49 PM, Development wrote: > > > Among the myriad of problems I'm having with this application a new one > developed when I began adding a shadow to text. > > The default text shadows look terrible on iPhone. This I subclassed > UILabel and did an override of drawTextInRect > > > > Well in order to draw with the correct colors I have had to do all my > custom stuff and then call [super drawTextInRect:rect]; > > > > It all works until an Italic font is used. Then the last maybe 5 pixel > are cut out of the text. I've attempted to adjust both the bounding box of > the parent view and the subclassed label both, and it does not seem to > change the views at all. So I'm not entirely sure how but I'm screwing up > adjusting a rectangle… (Hoiw hard is it to add 6 pixels to width of a darn > rect?) > > Anyway. So I attempted to use a string drawing method, which would among > other things allow me to set the alignment. This works, until I click the > text (which selects it) And it also fails to draw in the correct color. > (Always black instead of whatever it should be) > > > > Is string drawing possible if I want color? I need to override to get > nice shadows but it creates this nightmare. > > > >CGSize myShadowOffset = self.offset; > >float myColorValues[] = {0, 0, 0, self.depth}; > > > >CGContextRef myContext = UIGraphicsGetCurrentContext(); > >CGContextSaveGState(myContext); > > > >CGColorSpaceRef myColorSpace = CGColorSpaceCreateDeviceRGB(); > >CGColorRef myColor = CGColorCreate(myColorSpace, myColorValues); > >CGContextSetShadowWithColor (myContext, myShadowOffset, self.spread, > myColor); > > > >CGSize newSize = rect.size; > >CGSize imgSize = [self.text sizeWithFont:self.font]; > >imgSize.width +=6; //this does nothing > > //everything below adjusts for the shadow which is a flipping train > wreck of its own. > > CGPoint p; > > CGFloat x=0.0,y=spread; > > > >if (myShadowOffset.width <=0) { > >x =((newSize.width - > (imgSize.width+(spread*2)))/2)+abs(myShadowOffset.width); > >} > > else if(myShadowOffset.width >0){ > > x =0; > > } > > p = CGPointMake(x, y); > > > >rect.origin = p; > >rect.size = imgSize; > > > >[super drawTextInRect:rect]; > > > >CGColorRelease(myColor); > >CGColorSpaceRelease(myColorSpace); > > > >CGContextRestoreGState(myContext); > ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Custom Colors as UITableViewCell background colors
Hello all, We’re creating a custom UIColor pattern (using +[UIColor colorWithPatternImage:]) and setting it as the background color of our table view cell. This works great—and avoids several headaches with rounded corners and grouped table views—except for one thing: when dragging a cell from one row to another, there’s a momentary flash on the selected cell and its neighbors. The flash appears to be whatever color is at the bottom-left of the cell, so probably at point (0,0) in the graphics context. Is there a method we can override to prevent this from occurring, or a better way to set a custom background color/image for a cell and keep its rounded corners in grouped style table views? Jeff Kelley ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: From a view rect to a screen rect
UIView has some convenience methods you can use to convert a CGRect to and from different views’ coordinate systems. Look at the documentation for -convertRect:fromView:<http://developer.apple.com/library/ios/documentation/uikit/reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-BBCDBGGG>for an example. Now, UIScreen isn’t a view, but you can probably combine its -applicationFrameinstance method with the UIWindow (which *is* a view) to get something approximating the screen’s frame relative to your view’s coordinate system (which is what I think you’re asking for). Jeff Kelley On Fri, Jul 1, 2011 at 2:43 PM, Development wrote: > I am sure I am missing something simple but I've tried everything I can > find > > > I need to convert a rectangle in a NSView to a corresponding rectangle in > screen coordinates. > > originally I was using this code: > >selected.origin.x = selection.origin.x / ([imageView > frame].size.width/screen.size.width); >selected.origin.y = selection.origin.y / ([imageView > frame].size.height/screen.size.height)+25; >selected.size.height = selection.size.height / ([imageView > frame].size.height/screen.size.height); >selected.size.width = selection.size.width / ([imageView > frame].size.width/screen.size.width); > > > and it worked. However I have had to change the means by which I was > capturing the screen to CGDisplayCreateImageForRect > > I want to select an area in a view that represents the entire screen. I > need that rectangle then to be translated to the correct size and origin in > screen coordinates. > > The above code creates a rectangle of the correct size but the origin is so > far off I cannot image how to fix it. > > I have tried having the view itself use convertRectToBase passing the > screen bounds. This creates a rectangle of the correct size but the origin > is always, no matter what, 15,183. > I'm totally lost here and don't even know what to search for now that my > other attempts have failed. > Could some one help me out? > I'm hoping to find something with low overhead as clicks are a factor. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Windows cryptography
I would have a look at what's available through Cygwin. With any luck something like OpenSSL is available and has the features you're looking for. Jeff Kelley On Friday, July 1, 2011, Daniel Wambold wrote: > Hello. I have an iPhone app (SDK 4.3) that uses symmetric key encryption (AES > 256, through the CommonCrypto library). I have the parameters set to use > pkcs7 padding, and an iv of all zeros (CBC mode). My question (somewhat off > the lists's topic, I'm afraid) is that I need to help our IT people get a > file encrypted in this format on a Windows system. I was wondering if anyone > has accomplished this task. I strongly prefer that they use open-source code > (or something from a major developer, but it'll have to be free, then) if > possible, for obvious security reasons, but they don't seem to be able to > compile stuff, so I'm hoping to find an open source project that comes with a > precompiled binary. Any thoughts? Thanks for any help you might provide! > -Dan___ -- Jeff Kelley ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: So... we can't use UIWebView (with a delegate) on a page that's pushed onto a UINavigationController stack?
If you’re creating the web view in -viewDidLoad, you should probably release it and nil the pointer to it in -viewDidUnload, not -dealloc. Jeff Kelley On Sat, Jun 18, 2011 at 12:19 PM, Matt Neuburg wrote: > >"Important: Before releasing an instance of UIWebView for which you > >have set a delegate, you must first set the UIWebView delegate > >property to nil before disposing of the UIWebView instance. This can > >be done, for example, in the dealloc method where you dispose of the > >UIWebView." > > > >The delegate for the UIWebView is set up in the XIB file; it's pretty > >hokey to have to intervene in code to then disassociate the view from > >its delegate. Also, there is no "dealloc method where you dispose of > >the UIWebView", because that's done automatically when the view is > >popped off the navigation stack. > > What I do is start with a UIViewController subclass that creates the > UIWebView in viewDidLoad and disposes of it in dealloc, setting the delegate > to nil first, just as suggested in the docs. It's not clear to me why > creating the UIWebView in the nib would make any difference. m. > > -- > matt neuburg, phd = m...@tidbits.com, <http://www.apeth.net/matt/> > A fool + a tool + an autorelease pool = cool! > Programming iOS 4! > > http://www.apeth.net/matt/default.html#iosbook___ > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com > ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to intercepting click on send in Mail.app
Are you just trying to prevent the user from sending mail? There are much better alternatives, up to and including removing Mail.app from the /Applications folder. Jeff Kelley On Mon, May 30, 2011 at 10:51 AM, Nava Carmon wrote: > Actually the client is supposed to get a text from the mail message when > the user clicks send. This client is not a mail client and not is supposed > to send mail. > Is there some programmatic solution? > > Thanks > > On May 30, 2011, at 5:12 PM, Joanna Carter wrote: > > > Le 30 mai 2011 à 15:02, Nava Carmon a écrit : > > > >> Is it possible to intercept click on Send in Mac OS X Mail application? > >> I'm writing a client that on click on Send in Mail client should perform > certain action > > > > Why not just get Mail Act-on from Indev > http://www.indev.ca/MailActOn.html; it might save you reinventing the > wheel :-) > > > > Joanna > > > > -- > > Joanna Carter > > Carter Consulting > > > > > Nava Carmon > ncar...@mac.com > > "Think good and it will be good!" > > ___ > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com > ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: "Use them from only one thread at a time"
While that’s true for some classes (NSManagedObjectContext springs to mind) I think a more general way to say it would be “In most cases, although you can allocate instances of these classes on any thread, refrain from messaging an instance from more than one thread simultaneously.” Jeff Kelley On Thu, May 19, 2011 at 4:22 PM, Jerry Krinock wrote: > From the Apple's "Threading Programming Guide"… > > "Thread-Unsafe Classes. The following classes and functions are generally > not thread-safe. In most cases, you can use these classes from any thread as > long as you use them from only one thread at a time." > > I'm confused by the second sentence. Would it be correct to restate it > like this… > > "In most cases, although you can allocate instances of these classes on any > thread, each instance must receive messages only from the thread which > allocated it." > > ? > > Thanks, > > Jerry Krinock ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cocoa witch's broom
Agreed. You wouldn’t go to the hardware store and try to build something using every product they carried. As for the English, Wikipedia has an article for “Witch’s Broom” in English, so I would go with the first (“Cocoa Witch’s Broom”). Not that I would build the app. Jeff Kelley On Thu, Apr 14, 2011 at 11:56 AM, Allyn Bauer wrote: > I'm not sure creating a program to use every method in Cocoa is such a > great idea. What you should probably do instead is pick a small simple idea > and implement it. Perhaps you can make an app that lists the native trees of > Brazil and their diseases. :) > > Allyn > > On Apr 14, 2011, at 9:28 AM, Rodrigo Zanatta Silva wrote: > > > Hi. I am starting a project that will be a program to learn. My idea is > use > > every single function of Cocoa framework to show any behavior. For newbie > > like me, same time is difficult read the Apple docs and know what the > > function exact do, and what object I have to use in same cases. > > > > Ok, but firstly I have to chose a name. First I thought use "Cocoa with > > hate", a joke because exist the site "Cocoa with love" (I am not hate > Cocoa, > > not all the time :P ). But I thought this a bit bad. > > > > My new idea was use the disease of cocoa, namely "witch's broom". Here in > > Brazil, this is a pest and isn't a easy to prevent. There are two > meanings > > in this name. First is the joke because we have to "fight" with cocoa to > > learn. The disease itself is a (don't know the correct english name for > > this) huddle, congeries... of wood and leaves that look like a witch's > > broom. <http://www.sierrapotomac.org/W_Needham/WitchesBroom_R041220.htm> > And > > this will be the program, a lot of thing in a small place. > > > > Witch's broom isn't disease only for cocoa. So "Witch's broom" itself > isn't > > a good name for a program. My ideas was: > > > > - Cocoa Witch's Broom (Do this the most correct?) > > - Cocoa Witches Broom (Isn't it the correct?) > > - Cocoa's With Broom (With Broom of cocoa) > > - Cocoa's Witch's Broom > > - Witch's Broom of Cocoa > > - Witches Broom of Cocoa > > > > For you, English speaker, what is the most correct, The first is not the > > correct? Witches is the plural? Give-me a idea for this. > > ___ > > > > 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: > > http://lists.apple.com/mailman/options/cocoa-dev/allyn.bauer%40gmail.com > > > > This email sent to allyn.ba...@gmail.com > > ___ > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/slaunchaman%40gmail.com > > This email sent to slauncha...@gmail.com > ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iPhone animation puzzle
If I recall correctly, in iOS 4.0, this was reversed, but the next update changed the behavior to what we have now. On Mar 20, 2011, at 1:25 PM, WT wrote: > I seem to recall that one of the WWDC 2010 instructional videos - available > for free from Apple's developer site - mentions that the block version has > UIViewAnimationOptionAllowUserInteraction off by default. > > That being said, have you filed a document enhancement request? > > WT > > On Mar 20, 2011, at 1:59 PM, David Rowland wrote: > >> That did it. >> >> The "View Programmming Guide for iOS", discusses both methods and implies >> that their code samples are equivalent. They don't say, or I didn't see, >> that the option you mention is on by default for the begin/commit style and >> off for the newer block style. >> >> thanks, >> >> David >> >> >> >> On Mar 19, 2011, at 5:08 PM, Roland King wrote: >> >>> UIViewAnimationOptionAllowUserInteraction ? >>> >>> >>> >>> On Mar 20, 2011, at 5:42, David Rowland wrote: >>> >>>> This works. It fades the label to invisibility. >>>> >>>> label.alpha = 1.0; >>>> [UIView beginAnimations:nil context:nil]; >>>> [UIView setAnimationDuration:2.5]; >>>> label.alpha = 0; >>>> [UIView commitAnimations]; >>>> >>>> >>>> and so does this, >>>> >>>> label.alpha = 1.0; >>>> [UIView animateWithDuration:2.5 animations:^{label.alpha = 0.0;} ]; >>>> >>>> >>>> The documentation says the latter is now preferred and does the same thing >>>> as the former. In particular, both will >>>> start a separate thread for the animation. >>>> >>>> My problem is that the second method seems to block the main thread. While >>>> it is acting I cannot use any of the controls on the screen. The first >>>> method lets me do what I wish as it proceeds. >>>> >>>> >>>> Anyone have advice? >>>> >>>> thanks, >>>> >>>> David Jeff Kelley SlaunchaMan@gmail.com___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Multiple declarations of objc_msgSend_stret
On Feb 3, 2011, at 9:38 PM, Greg Parker wrote: > On Feb 3, 2011, at 6:18 PM, Jeff Kelley wrote: >> I’m trying to use objc_msgSend_stret to call -bounds on a UIScreen. I have >> the following code: >> >>> SEL bounds = NSSelectorFromString(@"bounds"); >>> CGRect screenBounds; >>> objc_msgSend_stret((void *)&screenBounds, screen, bounds); >> >> The declaration of objc_msgSend_stret in the Xcode code sense pop-up is as >> follows: >> >>> void objc_msgSend_stret(void * stretAddr, id self, SEL op, ...); >> >> But that’s not what message.h would leave me to believe (with some unrelated >> lines removed): >> >>> #if defined(__OBJC2__) >>> OBJC_EXPORT void objc_msgSend_stret(id self, SEL op, ...); >>> #else >>> /* For compatibility with old objc-runtime.h header */ >>> OBJC_EXPORT void objc_msgSend_stret(void * stretAddr, id self, SEL op, ...); >>> #endif >> >> So, if the declaration is actually the first (I’m compiling for iOS 4.2, so >> I’m pretty sure __OBJC2__ is defined), how do you use it and get the return >> value of the function? > > Both declarations are wrong: you cannot and must not call them directly. The > declaration of objc_msgSend_stret() cannot be expressed in C. > > The correct way to call objc_msgSend_stret() or any other objc_msgSend() > variant is to cast it to an appropriate function pointer type. Like this: > > CGRect (*msgSendFn)(id self, SEL _cmd); > msgSendFn = (CGRect(*)(id, SEL))objc_msgSend_stret; > CGRect screenBounds = msgSendFn(screen, @selector(bounds)); > > If the method had parameters, you would need to add them to the declaration > of the function pointer variable. > > > -- > Greg Parker gpar...@apple.com Runtime Wrangler That worked like a charm. Thanks, and don’t worry—this isn’t going in shipping code. :) Jeff Kelley slauncha...@gmail.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Multiple declarations of objc_msgSend_stret
I’m trying to use objc_msgSend_stret to call -bounds on a UIScreen. I have the following code: > SEL bounds = NSSelectorFromString(@"bounds"); > CGRect screenBounds; > objc_msgSend_stret((void *)&screenBounds, screen, bounds); The declaration of objc_msgSend_stret in the Xcode code sense pop-up is as follows: > void objc_msgSend_stret(void * stretAddr, id self, SEL op, ...); But that’s not what message.h would leave me to believe (with some unrelated lines removed): > #if defined(__OBJC2__) > OBJC_EXPORT void objc_msgSend_stret(id self, SEL op, ...); > #else > /* For compatibility with old objc-runtime.h header */ > OBJC_EXPORT void objc_msgSend_stret(void * stretAddr, id self, SEL op, ...); > #endif So, if the declaration is actually the first (I’m compiling for iOS 4.2, so I’m pretty sure __OBJC2__ is defined), how do you use it and get the return value of the function? Jeff Kelley slauncha...@gmail.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Waiting for UIWebView with Dispatch Semaphores
On Tue, Dec 21, 2010 at 11:59 AM, David Duncan wrote: > > Why do this synchronously at all? The web view already gives you a > notification, use that to generate your thumbnail and signal the caller. What I’m trying to do is create a thumbnail for a PowerPoint that, when clicked, opens a web view with the PowerPoint inside. I’d like it to be synchronous so that I can create thumbnails on demand if they aren’t already created. I’ll probably move forward with something that creates a full-size image asynchronously on downloading the PowerPoint, then dynamically resize that image to make my thumbnail, but this feels like something that *should* be possible. > Also consider that if the rendering takes a significant time, blocking the > main thread *will* cause your application to be killed by the watchdog timer. > Basically trying to do this synchronously is not only a waste of time, but a > dead end that will fail for anything but the simplest of scenes. The alternative, then, would be to find a way to render a PPT on a background thread, which UIWebView doesn’t seem suited for. Thanks for your comments. Jeff Kelley ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Waiting for UIWebView with Dispatch Semaphores
I’m trying to create a synchronous method on iOS (4.2.1) to create a thumbnail image for a PowerPoint file. To accomplish this, I want to load the file into a web view, then wait for it to load, then render its context into a new graphics context and save it to an image. Here’s what I have so far: http://pastie.org/1395434 I’ve tried adding the web view as a subview of the UIWindow to force it to render, but that didn’t seem to matter. The problem is line 26: waiting for the semaphore to be signaled blocks the thread, and the web view won’t load. None of the delegate methods will ever be called while I’m blocking. Is there a way to synchronously wait for the web view? All combinations of splitting things off on separate threads fall apart when I try to wait for the image to be created. Thanks in advance for any suggestions. Jeff Kelley ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone] Changing iPhone Application Language Programatically.
Tharindu, We had to do something similar and decided to eschew .lproj files entirely; we simply created an ivar in our app delegate to store the current language and switched out strings (stored in strings files) based on the current language. There’s no reason you couldn't do the same in your app. -Jeff Kelley On Monday, October 4, 2010, Tharindu Madushanka wrote: > Hi, > > I would like to know whether its possible to change to a language other than > provided list of languages in iPhone Settings. By default using localized > .lproj folders & .strings files we could make applicaton localized into > selected language. > > For example, Languages like Sinhala are not in those set of languages in > Settings. And there also does not have Sinhala Keyboard on iPhone. But > Sinhala unicode font is available from iOS 4 onwards which is nice even it > has some rendering issues. > > If I want to build a localized app for that language, is it legal and > whether its possible that I will create si.lproj directory and > programatically forcing the app to use strings in that folder ?? > > > Thanks and Kind Regards, > > Tharindu. > tharindufit.wordpress.com -- Jeffrey R. Kelley slauncha...@gmail.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: autorelease: how does this work!? (if at all)
Blocks do retain objects that are passed in, so that's probably what's happening. Also, keep in mind that autoreleased objects aren't freed immediately; it happens when the run loop completes. You should always act as if it does happen immediately, but it isn't always true. Jeff Kelley On Jun 18, 2010, at 11:00 AM, Jonny Taylor wrote: > I've just been looking back at some code that has been working fine for me > for a while, and as far as I can see it shouldn't actually work! I'd be > interested for peoples' comments. The code is as follows: > > dispatch_async(queue1, > ^{ > NSImage *theImage = [frame GetNSImage]; > NSData *tiffRep = [theImage TIFFRepresentation]; > dispatch_async(queue2, > ^{ > [tiffRep writeToFile:[NSString stringWithFormat:@"%...@%d.tif", > [[frame Camera] ExportFilePrefix], > [frame FrameNumber]] > atomically:YES]; > }); > [theImage release]; > }); > > Work running on serial queue "queue1" calculates a TIFF representation for an > image, and then schedules work on serial queue "queue2" to write that data to > disk. What I can't work out is why tiffrep isn't autoreleased as soon as the > outer block completes. Is the compiler/runtime being clever enough to retain > it because it is going to be needed in the inner block (if so: very clever!)? > If not, am I just getting lucky here with exactly when/how grand central does > its autorelease cleanup? Or maybe the TIFF representation and/or my frame > data is still being retained elsewhere for a while (possible, depending on > how the thread timings work out...). > > I'm pretty new to Cocoa so I'm keen to understand this properly - I'd be > interested to hear peoples thoughts on this: is what I am doing ok, or do I > need to add some explicit retain/releasing of tiffRep? > > Cheers > Jonny ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: send computer to sleep
If you need to make the computer sleep immediately, you can use the command "/usr/bin/pmset sleepnow". Jeff Kelley slaun...@umich.edu On May 26, 2010, at 5:01 PM, Julian. wrote: > what is the correct way to send the computer to sleep? i couldn't find > anything in the documentation, except appleevents... > > thanks, Julian. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSKeyedArchiver: confusion
Right, but in your original e-mail, you said, "When I open the file the old junk is all there." If you want the data to be in the file then you'll need to save it to the file. When you create the NSMutableData object, it's copied out of the file and into memory; you are not operating directly on the file. What happens if you create a keyed unarchiver immediately after the code you sent us and unarchive the object in question? Jeff Kelley University of Michigan On May 18, 2010, at 5:21 PM, Matthew Weinstein wrote: > My mistake for not being clear: > I have an NSData in an object; > I read that data using a keyedArchiver to get to the chunk I want. > > I want to replace a chunk of that data with another using the same key. (the > file part is immaterial). > > > On May 18, 2010, at 2:10 PM, Jens Alfke wrote: > >> >> On May 18, 2010, at 1:40 PM, Matthew Weinstein wrote: >> >>> The problem: The old @"codedDataArray" is not replaced! When I open the >>> file the old junk is all there. The old array is not discarded and replaced >>> with the new (myRecs) array. So I cannot use NSKeyedArchiver like an >>> NSMutableDictionary? >> >> I’m not sure I understand. Were you expecting the code you posted to write >> to the file? But nowhere in that code did you specify what file to write to. >> Archivers don’t directly know about files; they work on in-memory data. >> (Yes, there are convenience class methods for reading and writing a file, >> but they just call NSData methods to transfer the data to/from a file.) >> >> It sounds like what you want to do is call [NSKeyedArchiver >> archiveRootObject: obj toFile: file]. >> >> —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Authenticate NSFileManager Operations
Be sure NOT to redistribute the Adobe AIR framework unless you have prior written permission from Adobe. Jeff Kelley slaun...@umich.edu Campus Computing Sites Information and Technology Services University of Michigan On May 5, 2010, at 11:57 AM, k...@highrolls.net wrote: > I was using PackageMaker and it installed the framework. In a second step to > install an adobe air application the installer failed and that is why I went > to roll my own. > > -koko > > > On May 5, 2010, at 9:51 AM, Mike Abdullah wrote: > >> Are you writing an installer? If so, don't. Use the system-supplied one. >> >> On 5 May 2010, at 16:32, k...@highrolls.net wrote: >> >>> I am using >>> >>> - (BOOL)copyItemAtPath:(NSString *)srcPath toPath:(NSString >>> *)dstPatherror:(NSError **)error >>> >>> to copy a framework to /Library/Frameworks. >>> >>> But first I use >>> >>> - (BOOL)removeItemAtPath:(NSString *)path error:(NSError **)error >>> >>> >>> On my system all is well. On a user system I get >>> >>> You do not have appropriate access privileges. >>> >>> On the remove step. >>> >>> How does one invoke authentication for NSFileManager operations? >>> >>> -koko >>> ___ >>> >>> 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: >>> http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net >>> >>> This email sent to cocoa...@mikeabdullah.net >> >> > > ___ > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/slauncha%40umich.edu > > This email sent to slaun...@umich.edu > > ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com