Re: Auto-layout, Forcing a top-level view to hug its contents

2022-11-05 Thread Steve Christensen via Cocoa-dev
It should be fine if the view is offscreen as long as it’s part of the active 
view hierarchy. I would also suggest looking at the view controller 
viewDidLayoutSubviews() method to see if you could do what you want there.

> On Nov 4, 2022, at 9:25 PM, Sandor Szatmari  
> wrote:
> 
>> On Nov 4, 2022, at 23:05, Steve Christensen via Cocoa-dev 
>>  wrote:
>> 
>> The view hierarchy doesn’t go through a layout pass until after it is added 
>> to a live view or window. At awakeFromNib time it’s still essentially a 
>> snapshot of the layout in the nib since it hasn’t yet been inserted into the 
>> “context” that will allow the layout engine to determine how big all the 
>> views actually need to be.
> 
> Would an offscreen view or window allow it to be laid out and examine prior 
> to insertion in a live view/window?  Assuming this was necessary… of course.
> 
> 
> Sandor
> 
>>> On Nov 3, 2022, at 5:39 PM, Eyal Redler via Cocoa-dev 
>>>  wrote:
>>> 
>>> I have a view in a nib, the constraints are setup so that the view should 
>>> expand/contract to fit the contents and the nib is localized for several 
>>> languages. When I check the frame size of the view in awakeFromNib the size 
>>> I get is the same as the size set in the nib.
>>> I tried forcing the view to resize by calling layout but this didn't change 
>>> the frame size.
>>> Is there a way to force the view to resize, before putting it on the screen?
>>> 
>>> TIA
>>> 
>>> Eyal Redler
>>> 
>>> "If Uri Geller bends spoons with divine powers, then he's doing it the hard 
>>> way."
>>> --James Randi
>>> www.eyalredler.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: Auto-layout, Forcing a top-level view to hug its contents

2022-11-04 Thread Steve Christensen via Cocoa-dev
The view hierarchy doesn’t go through a layout pass until after it is added to 
a live view or window. At awakeFromNib time it’s still essentially a snapshot 
of the layout in the nib since it hasn’t yet been inserted into the “context” 
that will allow the layout engine to determine how big all the views actually 
need to be.

> On Nov 3, 2022, at 5:39 PM, Eyal Redler via Cocoa-dev 
>  wrote:
> 
> I have a view in a nib, the constraints are setup so that the view should 
> expand/contract to fit the contents and the nib is localized for several 
> languages. When I check the frame size of the view in awakeFromNib the size I 
> get is the same as the size set in the nib.
> I tried forcing the view to resize by calling layout but this didn't change 
> the frame size.
> Is there a way to force the view to resize, before putting it on the screen?
> 
> TIA
> 
> Eyal Redler
> 
> "If Uri Geller bends spoons with divine powers, then he's doing it the hard 
> way."
> --James Randi
> www.eyalredler.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: Retrieving the EXIF date/time from 250k images

2022-08-16 Thread Steve Christensen via Cocoa-dev
You mentioned creating and managing threads on your own, but that’s what 
NSOperationQueue —and the lower-level DispatchQueue— does. It also will be more 
efficient with thread management since it has an intimate understanding of the 
capabilities of the processor, etc., and will work to do the “right thing” on a 
per-device basis.

By leveraging NSOperationQueue and then keeping each of the queue operations 
focused on a single file then you’re not complicating the management of what to 
do next since most of that is handled for you. Let NSManagedObjectQueue do the 
heavy lifting (scheduling work) and focus on your part of the task (performing 
the work).

Steve

> On Aug 16, 2022, at 8:41 AM, Gabriel Zachmann  wrote:
> 
> That is a good idea.  Thanks a lot!
> 
> Maybe, I can turn this into more fine-grained, dynamic load balancing (or 
> latency hiding), as follows:
> create a number of threads (workers);
> as soon as a worker is finished with their "current" image, it gets the next 
> one (a piece of work) out of the list, processes it, and stores the iso_date 
> in the output array (dates_and_times).
> Both accesses to the pointer to the currently next piece of work, and the 
> output array would need to be made exclusive, of course.
> 
> 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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Retrieving the EXIF date/time from 250k images

2022-08-16 Thread Steve Christensen via Cocoa-dev
One way to speed it up is to do as much work as possible in parallel. One way 
—and this is just off the top of my head— is:

1. Create a NSOperationQueue, and add a single operation on that queue to 
manage the entire process. (This is because some parts of the process are 
synchronous and might take a while and you don’t want to block the UI thread.)

2. The operation would create another worker NSOperationQueue where operations 
are added that each process a single image file (the contents of your `for` 
loop).

3. The manager operation adds operations to the worker queue to process a 
reasonable chunk of the files (10? 50?) and then waits for those operations to 
complete. (NSOperationQueue has something like a “wait until done” method.) It 
then repeats until all the image files have been processed.

4. As each chunk completes, it can report status to the UI thread via a 
notification or some other means.

Unlike your synchronous implementation, below, the order of updates to that 
array is indeterminate. A way to fix it is to pre-populate it with as many 
placeholder items (NSDate.distantPast?) as are in imagefiles and then store 
iso_date at the same index as its corresponding filename. Another benefit is 
that there is a single memory allocation at the beginning rather than periodic 
resizes of the array (and copying the existing contents) as items are added.

And since all these items are running on different threads then you need to 
protect access to your dates_and_times array because modifying it is not 
thread-safe. One quick way is to create a NSLock and lock it around the array 
update:

[theLock lock];
dates_and_times[index] = iso_date;
[theLock unlock];

Anyway, another way to look at the process.

Steve


> On Aug 14, 2022, at 2:22 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I would like to collect the date/time stored in an EXIF tag in a bunch of 
> images.
> 
> I thought I could do so with the following procedure
> (some details and error checking omitted for sake of clarity):
> 
> 
>NSMutableArray * dates_and_times = [NSMutableArray arrayWithCapacity: 
> [imagefiles count]];
>CFDictionaryRef exif_dict;
>CFStringRef dateref = NULL;
>for ( NSString* filename in imagefiles )
>{
>NSURL * imgurl = [NSURL fileURLWithPath: filename isDirectory: NO];
> // escapes any chars that are not allowed in URLs (space, &, etc.)
>CGImageSourceRef image = CGImageSourceCreateWithURL( (__bridge 
> CFURLRef) imgurl, NULL );
>CFDictionaryRef fileProps = CGImageSourceCopyPropertiesAtIndex( image, 
> 0, NULL );
>bool success = CFDictionaryGetValueIfPresent( fileProps, 
> kCGImagePropertyExifDictionary, (const void **) & exif_dict );
>success = CFDictionaryGetValueIfPresent( exif_dict, 
> kCGImagePropertyExifDateTimeDigitized, (const void **) & dateref );
>NSString * date_str = [[NSString alloc] initWithString: (__bridge 
> NSString * _Nonnull)( dateref ) ];
>NSDate * iso_date = [isoDateFormatter_ dateFromString: date_str];
>if ( iso_date )
> [dates_and_times addObject: iso_date ];
>CFRelease( fileProps );
>}
> 
> 
> But, I get the impression, this code actually loads each and every image.
> On my Macbook, it takes 3m30s for 250k images (130GB).
> 
> So, the big question is: can it be done faster?
> 
> I know the EXIF tags are part of the image file, but I was hoping it might be 
> possible to load only those EXIF dictionaries.
> Or are the CGImage functions above already clever enough to implement this 
> idea?
> 
> 
> Best regards, Gab.

___

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: Points vs pixels in a bash script

2020-06-08 Thread Steve Christensen via Cocoa-dev
I don’t have an answer for your question, and I know that this doesn’t actually 
answer it below, but it may still provide some info to help you move forward.

The windowing system is always working in points from a coordinates point of 
view. So window.frame and view.frame are in points, not pixels. This allows 
drawing to be abstracted across screens that have different point scales 
(pixel-to-point size ratio). You specify everything in points and what that 
means when it’s time for the actual drawing to occur on a particular screen is 
handled for you.

I would suggest that you check out the NSScreen class, which provides 
properties such as the frame (in points) and backingScaleFactor (pixel-to-point 
ratio), as well as methods to convert between point- and pixel-based NSRects. 
Since it’s possible to, for example, have a 2x Retina display as the main 
screen and plug in an older 1x display, then move the window so it straddles 
the two screens, then there will not be a single scale value when calculating 
the number of pixels per point.

You can do things like iterate over all attached screens and find the largest 
backingScaleFactor, then use that to calculate the pixel size for an image, for 
example.


> On Jun 8, 2020, at 2:43 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I know this mailing list might not be the perfect fit for my question,
> but maybe someone has an idea.
> 
> I have a problem converting points (I think) to pixels in a bash script.
> I'd rather not write an extra C/Cocoa utility for that.
> 
> Using
>   system_profiler SPDisplaysDataType
> I can retrieve the size of a Mac's display in pixels. 
> 
> However, the command
> 
>   tell application "System Events" to get the size of every window of every 
> process
> 
> (which I execute from my bash script using osascript) apparently does NOT 
> return window sizes in pixels. I guess it's the strange "Apple points" units. 
> According to my experiments, on my MacBook Pro Retina, for instance, a 
> fullscreen app (e.g., Keynote presentation) has a window size of 1680 x 1050.
> By contrast, system_profiler reports 2880 x 1800.
> 
> So, the question is: how can I determine the screen size of a Mac from my 
> bash script in the same units like "System Events" uses? 
> Or, how can I determine the factor by which I have to convert pixels into 
> those other units?
> 
> 
> Many thanks in advance for any insights or hints.
> 
> 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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Relieving memory pressure

2020-06-07 Thread Steve Christensen via Cocoa-dev
For slide shows that I’ve seen, they typically display each image for several 
seconds at a time. If that’s the case, why can’t you just load the next image 
from disk on a background queue while the current image is being displayed and 
not have to worry about memory usage needed to cache multiple images? (I am 
assuming that you’ll need to load each image once anyway.)

If caching is required—apologies if I missed the “why” in earlier comments—then 
have you looked at NSCache? From the docs:

The NSCache class incorporates various auto-eviction policies, which ensure 
that a cache doesn’t use too much of the system’s memory. If memory is needed 
by other applications, these policies remove some items from the cache, 
minimizing its memory footprint.


> On Jun 7, 2020, at 5:31 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Good question.
> 
> Well, some users want to feed my app with image files of 100 MB, even up to 
> 400 MB (mostly jpeg compressed).
> Those images have resolutions of over 8k, sometimes over 10k.
> 
> The slideshow app needs to be able to zoom into those images with at least a 
> factor 2x scaling.
> 
> So I figured that if someone has a 4k monitor, creating thumbnails with 8k 
> resolution maximum should be sufficient.
> 
> An 8k x 8k image needs at least 200 MB (1 byte per channel).
> I don't know how CGImage stores the uncompressed images internally,
> but my experience seems to indicate that it uses significantly more memory 
> than that.
> (maybe it uses two bytes per channel, or even floats, or there is some other 
> aux data)
> 
>> What do you need a 1GB thumbnail for? There is no screen that can display 
>> that. For a slideshow app you could scale your thumbnails at creation time 
>> to the users biggest screen pixel size, don’t you think?
>> 
>> Christos Konidaris

___

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: Is CGImage... thread-safe?

2020-05-27 Thread Steve Christensen via Cocoa-dev

> On May 27, 2020, at 3:03 PM, Steve Mills via Cocoa-dev 
>  wrote:
> 
>> I can't recall/reproduce, but it was definitely *inside* 
>> CGImageSourceCreateThumbnailAtIndex().
>> 
>> If there is no image a tinder 0, shouldn't it just return NULL gracefully?
> 
> We don’t know that. There are many routines that throw exceptions when the 
> index is out of bounds. You should be calling CGImageSourceGetCount first to 
> make sure there’s an image at 0.

Right. If you look at the docs 
,
 it says that the result is “A CGImage object. …”. It doesn’t say “A CGImage 
object or NULL. …”. That suggests that you need to provide a valid index.
___

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: Swift -> Obj-C: return __kindof Something

2019-11-11 Thread Steve Christensen via Cocoa-dev
Yep, I understand what it does. I’m trying to get the same class-or-subclass 
behavior during compilation. I’d looked at the stack overflow article earlier, 
so I’ll check out the Swift forum to see what’s there. Thanks.

> On Nov 11, 2019, at 4:43 PM, Quincey Morris 
>  wrote:
> 
>> On Nov 11, 2019, at 15:07 , Steve Christensen via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>> 
>> Some existing Obj-C methods are of the form:
>> 
>>  + (nullable __kindof NSManagedObject) someFooThing;
>> 
>> Right now I have
>> 
>>  class var someFooThing: NSManagedObject?
> 
> AFAIK, “__kindof” only affects the ability to assign one Obj-C class pointer 
> to a variable of a different but compatible (kind of) type. It doesn’t change 
> the actual type of the variable, nor does it (again AFAIK) change the ability 
> to assign without errors in Swift. Also see here for some informative 
> discussion:
> 
>   https://stackoverflow.com/questions/31399208/ios-kindof-nsarray 
> <https://stackoverflow.com/questions/31399208/ios-kindof-nsarray>
> 
> I suggest you ask about this on forums.swift.org <http://forums.swift.org/>. 
> If there’s an alternative, someone there will know.

___

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


Swift -> Obj-C: return __kindof Something

2019-11-11 Thread Steve Christensen via Cocoa-dev
I’m working on an Obj-C app that got started a bunch of years ago and thought 
that I would start migrating some of the smaller pieces over to Swift.

Some existing Obj-C methods are of the form:

+ (nullable __kindof NSManagedObject) someFooThing;

Right now I have

class var someFooThing: NSManagedObject?

but that generates a bunch of warnings saying there are incompatible pointer 
type, so Obj-C callers will need to cast the result to the specific subclass 
type:

SonOfFoo sonOfFoo = (SonOfFoo)SonOfFoo.someFooThing;

which was what the original method handled automagically.

I tried the generics route but Xcode complains because it will be used in 
Obj-C. Obviously I can just go through and cast to clean up the warnings, but 
if there’s a nicer solution then I’d rather go that route.

I’ve been searching around this afternoon trying to see if anyone else has run 
across this. I haven’t found anything yet, but I don’t know if that’s due to 
poor search terms, or because someone more experienced with the process would 
say, “well, of course you can’t do that”. Any help?

Thanks,
Steve

___

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: CABasicAnimation does not animate bounds.origin of a layer

2019-09-14 Thread Steve Christensen via Cocoa-dev
First guess would be not to explicitly set -anchorPosition. It defaults to 
(0.5, 0.5), which refers to the middle of the bounds, and transforms (like 
scaling) are applied relative to that position.


> On Sep 14, 2019, at 6:25 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Maybe, I haven't understood how the animation of the bounds property works,
> or the bounds property of a CALayer itself ,
> or I am making a stupid mistake.
> 
> Here is my code:
> 
>CALayer * imgLayer = [CALayer layer];
>imgLayer.contents= (__bridge id) imageRef;
>imgLayer.delegate= nil;
>imgLayer.opacity = 1.0;  
>imgLayer.anchorPoint  = CGPointMake( 0.0, 0.0 );
>imgLayer.zPosition   = -1.0;   
> 
>CABasicAnimation * anim = [CABasicAnimation animationWithKeyPath: 
> @"bounds"];
>anim.timingFunction = [CAMediaTimingFunction functionWithName: 
> kCAMediaTimingFunctionLinear];
>anim.duration  = 5;// sec
>anim.autoreverses  = YES;
>anim.repeatCount  = 100;  // = 
> forever
> 
>NSRect from_rect = NSMakeRect( 100.0, 100.0, 200.0, 200.0 );
>anim.fromValue= [NSValue valueWithRect: from_rect ];
>NSRect to_rect = NSMakeRect( 200.0, 200.0, 300.0, 300.0 );
>anim.toValue = [NSValue valueWithRect: to_rect ];
> 
>[imgLayer addAnimation: anim forKey: @"myBoundsAnim"];
> 
> 
> What I am seeing is that the image gets scaled (from  200 to 300 
> width/height) which is fine,
> but it always sits in the lower left corner of the screen (I am working under 
> macOS).
> 
> I want the lower left corner of the image to be animated , too.
> (Eventually, the animation will be a bit more complex, but for now I am just 
> trying to understand this.)
> 
> What am I missing? or going wrong?
> 
> I guess I could achieve the effect by animating the position property of the 
> layer,
> but I'd rather prefer to understand what is going on.
> I have also re-read the "Core Animation Basics" , but it doesn't explain the 
> meaning of bounds.origin.
> In the drawings, it's always (0,0).
> 
> Thanks a lot in advance for any insights.
> 
> 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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSManagedObject.managedObjectContext is nil???

2019-03-28 Thread Steve Christensen
Is it possible that the entity is retained but has been deleted from the MOC? I 
vaguely recall seeing this myself at one point in the dim past.

> On Mar 27, 2019, at 1:18 PM, Rick Mann  wrote:
> 
> I can't tell. I don't believe I have any unreferenced MOCs.
> 
>> On Mar 27, 2019, at 13:08 , Dave Fernandes  
>> wrote:
>> 
>> Just to clarify, the moc exists, but the reference to it is nil? Or has the 
>> moc, itself, been deallocated?
>> 
>>> On Mar 27, 2019, at 3:40 PM, Rick Mann  wrote:
>>> 
>>> This is proving very hard to diagnose, as it doesn't always happen. I tried 
>>> observing -managedObjectContext, but it never gets called with a nil value. 
>>> Moreover, my entity's -dealloc method is sometimes called even though none 
>>> of the -awake methods gets called. This is a complex app with a lot of 
>>> async operation, so this entity gets created and destroyed often, making it 
>>> that much harder to figure out exactly what's going on.
>>> 
>>> I can bulletproof the place where the crash occurs when the moc is nil, but 
>>> I'd really like to track down the underlying problem.
>>> 
 On Mar 27, 2019, at 12:17 , Mike Abdullah  wrote:
 
 Given the number of objects Core Data is designed to juggle, managing that 
 number of weak references might well affect performance. Besides, wouldn’t 
 you still the same result, that your object has a nil reference to the 
 context because the context has been deallocated?
 
 Furthermore, I think you can also observe this affect on deleted objects 
 once the context has been saved, if you’re still holding a reference to 
 any such objects.
 
 Mike.
 
 Sent from my iPhone
 
> On 26 Mar 2019, at 21:57, Rick Mann  wrote:
> 
> The implication there is that an object has a weak reference to the MOC? 
> Ah, in the header I see it's `assign`. I wonder why they do that and not 
> `weak`.
> 
> Thanks, I'll look into it.
> 
>> On Mar 26, 2019, at 14:50 , Richard Charles  
>> wrote:
>> 
>> You have retained the managed object outside the managed object context.
>> 
>> --Richard Charles
>> 
>> 
>>> On Mar 26, 2019, at 1:04 PM, Rick Mann  wrote:
>>> 
>>> I'm seeing a situation where my NSManagedObject's managedObjectContext 
>>> is nil. It doesn't happen all the time though. Any idea why? Thanks!

___

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: My eyes are failing me.

2019-02-22 Thread Steve Christensen
Alex, is there any reason you couldn’t have used one of these?

[self.sharedData.webServicesURL URLByAppendingPathComponent:@"login"]
[self.sharedData.webServicesURL URLByAppendingPathComponent:@"login" 
isDirectory:{YES|NO}]


> On Feb 22, 2019, at 9:40 AM, Alex Zavatone  wrote:
> 
> There are 2 problems here.
> 
> The description is non standard and misleading and the /api string is 
> stripped from the URL that it indicates it will use in that URL.  Look.
> 
> (lldb) po [[NSURL URLWithString:@"/login" 
> relativeToURL:self.sharedData.webServicesURL] absoluteURL]
> https://home-qa.mrcooper.com/login
> 
> (lldb) po [NSURL URLWithString:@"/login" 
> relativeToURL:self.sharedData.webServicesURL] 
> /login -- https://home-qa.mrcooper.com/api
> 
> See how in the top output that /api is stripped from the URL that it will use 
> while it is displayed in the output on the bottom?
> 
> Damn misleading.  
> 
> 
> 
> 
> 
> 
> Sent from my iPad
> 
>> On Feb 22, 2019, at 11:24 AM, Alex Zavatone  wrote:
>> 
>> Of course I should have said, “produces what appears to be an incorrect 
>> result.”
>> 
>> Have I tried it? No.  I have not because it is telling me that the url I 
>> tried to create is nothing like the URL I tried to create.
>> 
>> Spending some time looking at it this morning and testing against the 
>> working string, it is apparent that the /api gets stripped off the URL when 
>> using relativeToURL.  Look at this.
>> 
>> (lldb) po self.sharedData.webServices
>> home-qa.mrcooper.com/api
>> 
>> (lldb) po self.sharedData.webServicesURL
>> https://home-qa.mrcooper.com/api
>> 
>> (lldb) po [[NSURL URLWithString:[NSString stringWithFormat:@"%@%@%@", 
>> @"https://;, self.sharedData.webServices, @"/login"]] absoluteURL]
>> https://home-qa.mrcooper.com/api/login
>> 
>> (lldb) po [[NSURL URLWithString:@"/login" 
>> relativeToURL:self.sharedData.webServicesURL] absoluteURL]
>> https://home-qa.mrcooper.com/login
>> 
>> See how relativeToURL: strips off the /api text from the URL?
>> 
>> 
>> So strange why they thought it a good idea to output the description and 
>> debugDescription that way AND strip off part of the URL.
>> 
>> Argh.  Thanks for the second (and third) set of eyes.
>> Alex Zavatone
>> 
>> 
>> Sent from my iPad
>> 
>>> On Feb 22, 2019, at 10:48 AM, Jens Alfke  wrote:
>>> 
>>> 
>>> 
 On Feb 22, 2019, at 8:39 AM, Alex Zavatone  wrote:
 
 self.loginURL = [NSURL URLWithString:@"/login" 
 relativeToURL:self.sharedData.webServicesURL]; // // WHY does this not 
 work? It does "/login -- https://qa-home.mrcooper.com/api;
>>> 
>>> Because NSURL’s .description property has a stupid way of printing a 
>>> relative URL.
>>> 
>>> The actual URL is correct, as you’ll see if you do something like `po 
>>> self.loginURL.absoluteString`. It should return ` 
>>> https://qa-home.mrcooper.com/login`.
>>> 
>>> Moral of the story: Always use .absoluteString to convert an NSURL to a 
>>> string, never .description or something that calls it implicitly.
>>> 
>>> —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: assertion failure

2018-04-07 Thread Steve Christensen
It's not uncommon to have a method throw an exception when you make a 
programming error so that you get immediate feedback. Not knowing offhand which 
method(s) were called, my guess would be that they're designed to always 
succeed if you specify the correct parameter values, so the assertion is 
letting you know that your parameters aren't correct.

It's not like the case where, for example, you're trying to delete a file that 
may or may not be there. In general usage either of those cases is just as 
valid so the file system reports the error, if any, and lets your app decide 
what to do.


> On Apr 7, 2018, at 1:18 PM, Alan Snyder  wrote:
> 
> I understand that my program is doing it wrong. But is it normal to have an 
> assertion failure, rather than an error return?
> 
> 
>> On Apr 7, 2018, at 12:04 PM, Rob Petrovec  wrote:
>> 
>> It’s saying that you are doing it wrong.  Utility windows cannot go full 
>> screen.  You have yours set to go full screen.  It shouldn’t be.
>> 
>> —Rob
>> 
>> 
>>> On Apr 7, 2018, at 10:24 AM, Alan Snyder  
>>> wrote:
>>> 
>>> I am getting an assertion failure notice on the console when running a 
>>> small test program:
>>> 
>>> Assertion failure in -[AWTWindow_Panel _validateCollectionBehavior:], 
>>> /Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1504.83.101/AppKit.subproj/NSWindow.m:14741
>>> 
>>> (This message is on 10.12.6, the details are different on 10.13.)
>>> 
>>> When run under Xcode, there is more information: utility panels cannot be 
>>> fullscreen primary
>>> 
>>> My question—does this represent a bug in AppKit that I should report, or is 
>>> it trying to help me by explaining that my program provided an unsupported 
>>> set of style bits when creating a window?
>>> 
>>> Alan

___

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: Using NSFetchedResultsController with many-to-many relationship

2018-03-10 Thread Steve Christensen
Don't complicate your life by managing multiple NSFetchedResultsControllers. 
Just create a single one that returns Club entities. For your table view data 
source methods:

func numberOfSections(in tableView: UITableView) -> Int
{
return frc.fetchedObjects.count
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> 
Int
{
let club = frc.fetchedObjects[section] as! Club

return club.persons.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> 
UITableViewCell
{
let club = frc.fetchedObjects[indexPath.section] as! Club
let person = club.person[indexPath.row]

return self.cell(forPerson: person)
}

If your Club and Person entities will remain static while the table view is 
visible then you can just do the fetch once in viewDidLoad() and use the info 
you get back as-is. If your app supports some kind of async changes to your 
model data that affect which Clubs exist then you should implement the 
NSFetchedResultController delegate methods so that you know when those changes 
occur.

To watch for Person changes, you could set up KVO observing of the properties 
you're interested in. When observeValue(...) is called then reverse look-up the 
clubs of which the person is a member and reload cells corresponding to that 
person in each of its clubs:

...
if let person = object as! Person
{
var cellsToReload = [IndexPath]()

for club in person.clubs
{
if let section = frc.fetchedObjects.index(of: club),
   let row = club.persons.index(of: person)
{
let indexPath = IndexPath(row: row, section: section)

cellsToReload.append(indexPath)
}
}

if cellsToReload.count > 0
{
tableView.performBatchUpdates(
{
tableView.reloadRows(at: cellsToReload, with: .automatic)
},
completion: nil)
}
}
...


Steve


> On Mar 10, 2018, at 12:47 AM, Glen Huang  wrote:
> 
> Hi,
> 
> I have two models: Person and Club. They have a many-to-many relationship. I 
> want to display all people in a table view sectioned by clubs (which means 
> there might be duplicate people across sections). I wonder how to do that 
> with NSFetchedResultsController? NSFetchRequest never returns the same object 
> more than once. 
> 
> One solution I can come up with is to use multiple 
> NSFetchedResultsController, one for each section(club). But in my case people 
> are editable, so I’d like to also track changes. Listen to multiple 
> NSFetchedResultsController seems pretty cumbersome if not impossible 
> (especially with regard to the adding or removing of clubs, either because 
> everyone leaves a club or a person joins a new club).
> 
> I wonder if there is a direct way to achieve that or a better way to 
> approximate? 
> 
> Best
> Glen

___

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: Icon radio buttons

2018-01-24 Thread Steve Christensen
You could manage the button state yourself without a lot of code.


@IBOutlet var button1: NSButton// tag = 0
...
@IBOutlet var buttonN: NSButton// tag = N - 1

private var selectedPaletteButtonIndex: Int = 0
private var paletteButtons: [NSButton]

override func viewDidLoad()
{
super.viewDidLoad()

paletteButtons =
[
button1,
...
buttonN
]

paletteButtons[selectedPaletteButtonIndex].state = .on
}

@IBAction func paletteChanged(_ button: NSButton)
{
let newSelectedPaletteButtonIndex = button.tag

if selectedPaletteButtonIndex != newSelectedPaletteButtonIndex
{
paletteButtons[selectedPaletteButtonIndex].state = .off
paletteButtons[newSelectedPaletteButtonIndex].state = .on

selectedPaletteButtonIndex = newSelectedPaletteButtonIndex
}
}


> On Dec 20, 2017, at 5:04 PM, Casey McDermott  wrote:
> 
> Is there a way to have a palette of icon buttons act like radio buttons, 
> without use of the deprecated NSMatrix?  The goal is something like the 
> drawing tool palette in the Sketch sample app (or ancient MacDraw).
> 
> In IB, it is not possible to add an image to a NSButton with style radio. It 
> automatically changes to a bevel button when the image is added. Likewise, 
> with style rectangle, the type can't be radio.
> 
> Thanks,
> 
> Casey McD

___

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: Deciphering an error message on an iOS UITextField subclass.

2018-01-17 Thread Steve Christensen

> On Jan 17, 2018, at 5:24 PM, Alex Zavatone  wrote:
> 
> po [cell.dataField isKindOfClass:[UITextField class]]

Have you tried "print [cell.dataField isKindOfClass:[UITextField class]]", 
instead, possibly casting the result to bool? The debugger may be getting 
confused when you're asking it to print an object, but the method returns a 
bool.

___

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: Background fetch is never called

2017-12-13 Thread Steve Christensen
Are you calling -[UIApplication setMinimumBackgroundFetchInterval:] in 
-application:didFinishLaunchingWithOptions:? According to the documentation:

> Specifies the minimum amount of time that must elapse between background 
> fetch operations.
> 
> This property has no effect for apps that do not have the UIBackgroundModes 
> key with the fetch value in its Info.plist file. 
> 
> The default fetch interval for apps is 
> UIApplicationBackgroundFetchIntervalNever. Therefore, you must call this 
> method and set a fetch interval before your app is given background execution 
> time.


> On Dec 13, 2017, at 1:31 AM, Viacheslav Karamov <ubuntul...@yandex.ru> wrote:
> 
> Yes, I confirm that
> 
> 
> 12.12.17 23:16, Steve Christensen wrote:
>> Did you confirm that there is a UIBackgroundModes key in your app's 
>> Info.plist?
>> 
>> UIBackgroundModes
>> 
>>  fetch
>> 
>> 
>> 
>> 
>>> On Dec 12, 2017, at 6:23 AM, Viacheslav Karamov <ubuntul...@yandex.ru> 
>>> wrote:
>>> 
>>> I have configured Background Fetch at the "Capabilities" tab in my 
>>> Project's settings. Then added to the App delegate:
>>> 
>>> -(void)application:(UIApplication *)application 
>>> performFetchWithCompletionHandler:(void 
>>> (^)(UIBackgroundFetchResult))completionHandler
>>> {
>>> NSLog(@"### Received Backgroudn Fetch ###");
>>> 
>>> //Increase Badge Number
>>> [UIApplication sharedApplication].applicationIconBadgeNumber++;
>>> 
>>> 
>>> completionHandler(UIBackgroundFetchResultNewData);
>>> }
>>> 
>>> - (BOOL)application:(UIApplication *)application 
>>> didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
>>> {
>>> [[UIApplication sharedApplication] 
>>> setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
>>> 
>>> return YES;
>>> }
>>> 
>>> When I run my simple App on the real device (tested on iPad mini 2 with iOS 
>>> 10.2 and iPhone 6S running iOS 11.2) nothing happened during long time 
>>> period (more than 10h). I even tried to add "Remote Notifications" 
>>> capability and it also didn't help.
>>> 
>>> Regards,
>>> 
>>> Viacheslav.

___

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: Background fetch is never called

2017-12-12 Thread Steve Christensen
Did you confirm that there is a UIBackgroundModes key in your app's Info.plist?

UIBackgroundModes

fetch




> On Dec 12, 2017, at 6:23 AM, Viacheslav Karamov  wrote:
> 
> I have configured Background Fetch at the "Capabilities" tab in my Project's 
> settings. Then added to the App delegate:
> 
> -(void)application:(UIApplication *)application 
> performFetchWithCompletionHandler:(void 
> (^)(UIBackgroundFetchResult))completionHandler
> {
> NSLog(@"### Received Backgroudn Fetch ###");
> 
> //Increase Badge Number
> [UIApplication sharedApplication].applicationIconBadgeNumber++;
> 
> 
> completionHandler(UIBackgroundFetchResultNewData);
> }
> 
> - (BOOL)application:(UIApplication *)application 
> didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
> {
> [[UIApplication sharedApplication] 
> setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
> 
> return YES;
> }
> 
> When I run my simple App on the real device (tested on iPad mini 2 with iOS 
> 10.2 and iPhone 6S running iOS 11.2) nothing happened during long time period 
> (more than 10h). I even tried to add "Remote Notifications" capability and it 
> also didn't help.
> 
> Regards,
> 
> Viacheslav.

___

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: Avoiding color transformations in PNG/UIImage/CGImage ops?

2017-11-17 Thread Steve Christensen
It sounds like you're looking at image file data rather than buffers of pixel 
data. If so then I wouldn't make the assumption that the encoded bytes in two 
PNG files will be identical for identical images. Depending on how flexible the 
file format is, then particular parts of the encoded image could be written to 
different locations in the two files. It seems more reasonable to draw the 
images to compare into CGBitmapContexts configured identically and them compare 
the active portions (i.e., width * bytesPerPixel <= bytesPerRow) of the bitmap 
buffers.

As for color space to use, Apple recommends "that you use calibrated (or 
generic) color spaces instead of device color spaces. The colors in device 
color spaces can vary widely from device to device, whereas calibrated color 
spaces usually result in a reasonably accurate color." 
(https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/DrawColor/Tasks/UsingColorSpaces.html
 
)

Steve


> On Nov 16, 2017, at 6:31 PM, Rick Mann  wrote:
> 
> I'm trying to write a unit test for some code I wrote that generates one 
> image from another. In the main app, the source data comes from Open CV as a 
> buffer of 3 byte-per-pixel elements. My code generates a CGImage. In the unit 
> test, I load a saved version of one of those images from a PNG file to 
> UIImage, get at the buffer, pass it to my code, and then compare the result 
> to a saved version of that same output.
> 
> The saved version is a PNG. I load that, and then get the data buffer using
> 
>let fiData = fi.dataProvider?.data as Data?
> 
> I do a similar thing with the generated CGImage. Then I compare the two 
> buffers, byte by byte. They are similar, but contain differences (sometimes 
> more than I would expect). But if I save both as PNG and look at them in 
> Preview they look identical.
> 
> My guess is something's happening somewhere with color correction. In my 
> code, I make a CG(bitmap)Context, specifying device RGB color space (should 
> that be generic?). I don't really know what happens to the PNGs I save and 
> load.
> 
> Is there a way to ensure the bytes in the buffer are compressed and 
> decompressed exactly as written?

___

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: Getting immutable UIImage data pointer without copy?

2017-11-15 Thread Steve Christensen
On Nov 14, 2017, at 8:37 PM, Rick Mann  wrote:
> 
>> On Nov 14, 2017, at 20:18 , Jens Alfke  wrote:
>> 
>>> On Nov 14, 2017, at 8:11 PM, Rick Mann  wrote:
>>> 
>>> Maybe, at least for the bonus question. The bigger question is around the 
>>> copy.
>> 
>> Where pixmaps live is a pretty complex issue…
> 
> Well, then let me rephrase it as "unnecessary copies." In this case, I 
> (currently) need to manipulate the pixels to generate a new image. I will be 
> moving this to a Metal 2 filter soon enough, but for pre-iOS 11 users, I'd 
> still like to use as little memory as possible (we use a lot of memory in our 
> app).

Rick, if you're trying to work with pixel data in a buffer then how about 
something like this? It delivers premultiplied 8-bit RGBA pixels to manipulate. 
I believe the only buffer of any significant size should be the pixel buffer 
for the bitmap context. (The docs say that makeImage() is only supposed to do a 
buffer copy on write so it should be using the context's buffer.)

func manipulateImage(_ image: UIImage) -> UIImage
{
let imageBounds = CGRect(origin: CGPoint.zero, size: image.size)
let width   = Int(imageBounds.size.width)
let height  = Int(imageBounds.size.height)
let colorSpace  = CGColorSpaceCreateDeviceRGB()
let bitmapInfo  = CGBitmapInfo(rawValue: 
CGImageAlphaInfo.premultipliedLast.rawValue)

if let bitmap = CGContext(data: nil,
  width: width,
  height: height,
  bitsPerComponent: 8,
  bytesPerRow: 0,
  space: colorSpace,
  bitmapInfo: bitmapInfo.rawValue)
{
bitmap.draw(image.cgImage!, in: imageBounds)

let bytesPerRow = bitmap.bytesPerRow
var buffer  = bitmap.data!.bindMemory(to: UInt8.self, capacity: 
(bytesPerRow * height))

for row in 0 ..< height
{
var pixel = buffer

for _ in 0 ..< width
{
var red   = pixel[0]
var green = pixel[1]
var blue  = pixel[2]
var alpha = pixel[3]

processPixel(, , , )

pixel[0] = red
pixel[1] = green
pixel[2] = blue
pixel[3] = alpha

pixel += 4
}

buffer += bytesPerRow
}

if let processedCGImage = bitmap.makeImage()
{
return UIImage(cgImage: processedCGImage)
}
}

return 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: I noticed that my mail address is banned

2017-10-22 Thread Steve Christensen
高田氏、

The word 'pedophilia' in English is shōniseiai' in Japanese. At least in our 
part of the world, that word has a very negative connotation and its practice 
is illegal. That is why nobody will visit your website. I would suggest that 
you consider a different domain name and use a service like Google Translate to 
be sure that you understand what the meaning of an English word is in Japanese.

英語で「pedophilia」という言葉は日本語で「小児性愛」です。 少なくとも私たちの世界では、その言葉は非常に否定的な意味を持ち、その慣習は違法です。 
だから誰もあなたのウェブサイトを訪れるわけではありません。 
私はあなたが別のドメイン名を検討し、Google翻訳のようなサービスを使用して、英語の単語の意味が日本語であることを理解していることを確認することをお勧めします。

(Google翻訳の助けを借りて)


> On Oct 22, 2017, at 7:49 AM, 高田 明史  wrote:
> 
> Dear owner and everyone else,
> 
> Perhaps, i thought that the owner may not be seeing the sent mail,
> i decided to send it to the mailing list by describing circumstances.
> 
> I am Japanese.
> My English skill is very weak.
> 
> I think that there is no content that has a problem.
> However, i noticed that my mail address is banned.
> 
> I would like to stop it.
> 
> Originally, i know that i should write in English, but it is difficult to 
> describe in English properly.
> Because some members of the mailing list may understand Japanese, i will 
> describe circumstances in Japanese.
> 
> 
> My page: http://pedophilia.jp
> 
> Regards,
> p,t,a
> 
> From here it is in Japanese.
> 
> 本来は、英語で書くべきだとは分かっているのですが、英語で現在までの経緯をきちんと記載することは難しいので、日本語で以下に今までの経緯を記載します。
> 
> 1. 
>   
> 10月2日、自作プログラムを知ってもらいたかったので、Cocoa-devに自作プログラムに関するメールを送信した。送信後、メールに自分のWebページを記載し忘れていたことに気づいた。記載を忘れていた旨を書いたメールを送りたかったが、英語でどの様な文を書けばいいのかが分からなかった事と、慌てていたので、最初に送信したメールに返信するという形で2通目のメールを送信した。
> 
> 2. 
>   
> 何通かの返信があった、辞書を引きながら内容を理解しようとしたが、自分の英語の技能が低いため、文としての意味が良く分からなかった。ただ、ジョークと思われているらしい事と、ドメイン名が好ましくないということが書かれているということは分かった。
>   何かしらの返信をしたほうが良いという気持ちはあったが、英語で自分の意図をきちんと伝えるのは、難しいと思ったので、断念した。
> 
> 3.
>   メーリングリストからのメールがあまり届かなかったが、あまりメールのやり取りが活発ではないのだろうと思った。
> 
> 4.
>   Xcodeをversion 9に更新して、プログラムをビルドできるかを確認した。
> ビルドに失敗することに気づいたので、修正をした。
> 
> 5.
>   プログラムを更新した事とどの様な機能があるのかを記載したメールをCocoa-devに送信した。
> 
> 6.
>   自分が送信したメールが自分のメールアドレスになかなか届いていないので、
> 何かがおかしいと思い、とりあえず、Web上のCocoa-devのアーカイブを見てみた。
>   自分のアドレスには届いていないメールがかなりあることに気づいた。
>   何らかの理由で、メーリングリストから退会されているのではないかと思い、
>   もう一度、前回と同じメールアドレスで登録処理をしてみたが、登録できなかった。
>   メールアドレスに問題があるのかと思い別のメールアドレス(ドメイン部分は同じ)で、登録処理をしてみたが、登録できなかった。
>   メールアドレスが停止されているらしいことに気づいた。
> 7.
>   Cocoa-devのオーナーにメールアドレスの停止を依頼するメールを送った。
>   だが、1日待っても、返信はなかった。
> 8.
>   もしかすると、送信したメールをオーナーが見ていないのかもしれないと思い、
>   メーリングリストに、今までの経緯を記載して送信することにした。

___

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: Who owns a child view controller?

2017-07-14 Thread Steve Christensen
On Jul 14, 2017, at 8:09 AM, Jeremy Hughes <moon.rab...@virginmedia.com> wrote:
> 
>> On 14 Jul 2017, at 14:40, Steve Christensen <puns...@mac.com> wrote:
>> 
>> On Jul 14, 2017, at 3:50 AM, Jeremy Hughes <moon.rab...@virginmedia.com> 
>> wrote:
>>> 
>>> I’m still not entirely clear on when autorelease pools are used in Swift. 
>>> There is a WWDC video which says that they’re used in code that interfaces 
>>> with Objective-C, but Greg Parker’s comments in this thread indicate that 
>>> autorelease is also used behind the scenes in native Swift code - except 
>>> that in many cases the compiler is able to optimise it out of existence. 
>>> Apple’s Swift book doesn’t mention autorelease.
>> 
>> I think the hazard here is that you are trying to build a mental model of 
>> when to expect autorelease pools (or autorelease behavior in general) and 
>> when not to. Worse, that you might design your code to fit those 
>> expectations.
> 
> Apple’s documentation states that there are times that you do want to 
> consider the memory effects of autorelease pools (and suggests adding your 
> own pools to prevent large accumulations of dead objects during loops) - so 
> knowing when they are used isn’t irrelevant.

What I was getting at is that whether or not an object created by something 
other than your code is in an autorelease pool should be of no concern to you 
(at least with ARC). If your code assigns it to a strong variable, adds it to 
an array, etc., then its retain count will be incremented because your code is 
now becoming a [co-]owner of the object. Whether or not the retain count will 
be decremented someplace else due to an enclosing autorelease pool or some 
other mechanism will not affect that behavior.

If you explicitly create an autorelease pool, such as for reasons that you've 
mentioned above, then you need to be aware that something you created in the 
pool's scope, and want to continue existing beyond the pool's scope, could 
magically disappear when the pool is drained if you're not managing it 
correctly.

___

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: Who owns a child view controller?

2017-07-14 Thread Steve Christensen
On Jul 14, 2017, at 3:50 AM, Jeremy Hughes  wrote:
> 
> I’m still not entirely clear on when autorelease pools are used in Swift. 
> There is a WWDC video which says that they’re used in code that interfaces 
> with Objective-C, but Greg Parker’s comments in this thread indicate that 
> autorelease is also used behind the scenes in native Swift code - except that 
> in many cases the compiler is able to optimise it out of existence. Apple’s 
> Swift book doesn’t mention autorelease.

I think the hazard here is that you are trying to build a mental model of when 
to expect autorelease pools (or autorelease behavior in general) and when not 
to. Worse, that you might design your code to fit those expectations.

I think it's a lot safer to understand how strong/weak/unowned work and go from 
there. You do the appropriate thing to hang onto an object while you're using 
it and then do the appropriate thing when you're done with it (which might be 
as simple as setting a variable to nil). Once you're done with the object, it's 
somebody else's task to make sure that the right things happen at the right 
time (that's their right time, not yours).

___

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: Who owns a child view controller?

2017-07-12 Thread Steve Christensen
On Jul 12, 2017, at 1:16 PM, Jeremy Hughes  wrote:
> 
>> On 12 Jul 2017, at 19:25, Jens Alfke  wrote:
>> 
>>> 
>>> On Jul 12, 2017, at 10:57 AM, Jeremy Hughes  
>>> wrote:
>>> 
>>> Wouldn’t it be ARC (rather than the consumer) that is balancing retains?
>> 
>> Yes. ARC internally generates calls to -autorelease (or actually to some C 
>> functions in the runtime that invoke autorelease.)
> 
> Well, my original example was of native Swift objects that are released 
> instantly and Cocoa objects that are not, and you suggested that the Cocoa 
> objects are using autorelease - which makes sense, because Cocoa has to 
> support ARC and non-ARC code.
> 
> Is there any evidence that ARC is internally generating autorelease calls for 
> native Swift code?

It's also possible that, as an implementation detail, AppKit isn't 
disconnecting the view controller's view from the view hierarchy until it gets 
around to doing all the other view processing like redraws. If so then the view 
could be holding on to its view controller until that time. Or there's 
something else going on under the covers.

Unless it's really important for you to expect that the child view controller 
has disappeared immediately then it's probably better just to assume that it 
has (or will) and move on to other things.

___

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


UIWebView displays margins incorrectly with black background and paginationMode = UIWebPaginationModeLeftToRight

2017-05-04 Thread Steve Christensen
Xcode 8.3.1, iOS Simulator 10.3 and iOS 10.3.1


I am using a paginated UIWebView to display some HTML. Everything appeared to 
be working OK until I changed the CSS to set the background color to black and 
the foreground (text) color to white. Then I found that wherever there is a 
non-zero margin on an element then the space occupied by the margin is white, 
even though parent elements have a black background.

If I set the margins to zero and instead set the corresponding padding property 
then the content is drawn correctly, but that causes issues when a non-black 
background needs to be set on an element.

If I don't set webView.paginationMode then the HTML renders correctly.

I reduced the HTML to a simple test case that is reproducible, appended below. 
I'm stuck right now since I can't really peek inside the web view to see what 
it's thinking. Looking at the Simulator view in Safari just shows the expected 
properties, so no help there.

Has anybody else run across this and come up with a solution? Is this a known 
bug?

Thanks,
Steve

-


  Title
  
  
body,body * {background:#00; color:#ff}
p {margin-bottom:10px; margin-top:10px}
  


  Paragraph 1
  Paragraph 2



___

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: What generates NSURLErrorUnsupportedURL?

2017-02-08 Thread Steve Christensen
Thanks Greg (and Jens). The URLs are coming from a server that the app uses. I 
haven't seen these errors in the past so somebody was probably doing some 
tinkering and messed something up.


> On Feb 8, 2017, at 7:16 PM, Greg Parker <gpar...@apple.com> wrote:
> 
>> On Feb 8, 2017, at 2:44 PM, Jens Alfke <j...@mooseyard.com> wrote:
>> 
>>> On Feb 8, 2017, at 10:38 AM, Steve Christensen <puns...@mac.com> wrote:
>>> 
>>> The time between when the request is made and when it completes with an 
>>> error might be a minute or so, so the framework is immediately bailing on 
>>> the request. I'm wondering what part of the process generates the error. 
>>> Does the server return a non-200 status code or what?
>> 
>> The server is probably returning a redirect (301, 302 or 303) to a bogus URL.
> 
> NSURLErrorUnsupportedURL in a background session is specifically a complaint 
> that the URL is neither http nor https. Perhaps the server redirected to 
> something else?
> 
> 
>> There’s a delegate method you can implement to see the redirected URL, which 
>> could help you troubleshoot this. But it sounds like it’s the server’s fault.
> 
> The bad URL is also recorded in the NSError's userInfo dictionary as 
> NSURLErrorFailingURLStringErrorKey.
> 
> -- 
> Greg Parker gpar...@apple.com Runtime Wrangler


___

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

What generates NSURLErrorUnsupportedURL?

2017-02-08 Thread Steve Christensen
I am occasionally seeing a NSURLErrorUnsupportedURL (unsupported URL) error 
being returned by download tasks on a background NSURLSession, on iOS. Before 
you ask, the URL (https://…) is properly formed, [NSURL URLWithString:] returns 
a non-nil URL, and as an extra manual check I did an online validation of the 
URL on a couple of different websites to see if I missed something.

The time between when the request is made and when it completes with an error 
might be a minute or so, so the framework is immediately bailing on the 
request. I'm wondering what part of the process generates the error. Does the 
server return a non-200 status code or what? Searching for more detail in the 
docs, etc., hasn't yielded anything except comments from people saying to make 
sure that the scheme is specified.


___

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

UICollectionView cells sometimes drawn on top of section header

2017-01-06 Thread Steve Christensen
iOS 10.

I'm seeing some odd behavior where occasionally collection view cells are drawn 
on top of their section header view instead of behind it. When I use the view 
inspector in Xcode then I do, in fact, see the cells in front of the section 
header.

These are pretty generic cells that contain an image. The only thing special is 
that the image is loaded asynchronously and then set on the cells UIImageView 
in a completion block on the main thread.

Has anybody else run across this behavior before?


___

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: 12 hr vs 24 hr time display

2017-01-03 Thread Steve Christensen
On Jan 3, 2017, at 8:26 AM, Sandor Szatmari <admin.szatmari@gmail.com> 
wrote:
> 
> Steve,
> 
>> On Jan 3, 2017, at 10:17, Steve Christensen <puns...@mac.com> wrote:
>> 
>> In the Date & Time preference panel, I assume that you're referring to the 
>> option on the Clock tab. If so, those settings refer only to the menubar 
>> clock display.
> I just think it's weird that there are two checkboxes.  It seems odd to me 
> that one would want a 24 hr clock in the menu bar but not anywhere else.

The menubar clock settings also have options for displaying the time with or 
without seconds, showing AM/PM, showing the day of the week, and showing the 
date. These options all affect the final representation in the menubar, 
independent of the locale settings, but you're focusing on just one of these.

I have a little bit of experience with the menubar clock in the pre-OS X world 
so I happen to know that those particular options were present as early as 
1992, so people have been living with the arrangement for a long time.

>> If you notice in that same preference panel, on the Date & Time tab, there 
>> is a message at the bottom that says, "To set date and time formats, use the 
>> Language & Region preferences." Clicking the button takes you to that other 
>> panel, and there you will find a checkbox that lets you select 24-hour time.
> Yes, this is method 2 I referred to.  If you check the Language & Region 
> checkbox it overrides the Date & Time checkbox, enabling 24 hr time display 
> in the menu bar clock and disabling the Date & Time checkbox.  So clearly 
> someone at Apple sees there is at least a one direction connection between 
> these two checkboxes.

That's merely an implementation detail related to a private system feature. 
It's no different than if you were to put such an option in your app.

>> The Language & Region settings are what specify the locale that is used for 
>> formatting date and time values (among other things), which is why you see 
>> those changes reflected in the NSDateFormatter methods.
> Yes, this discrepancy (IMHO) is what I was asking about.  I don't see why the 
> option for the clock display would be separated from this option.
> 
> What I was asking for clarity on is the fact that there is no way to detect 
> that the user prefers 24 hr time display if they only choose method 1, the 
> Date & Time checkbox.  Should I allow my users to set 12 hr time but override 
> it to 24 hr time if the Language & Region checkbox is checked?  This doesn't 
> feel right.  I feel like Apple left room for ambiguity in their design here.

The locale settings, in the Language & Region preference panel, specifies the 
user's current preferences in terms of general time formatting. The clock 
settings specify the user's current preferences for the menubar clock. I don't 
see the ambiguity.


>>> On Jan 2, 2017, at 10:16 PM, Sandor Szatmari <admin.szatmari@gmail.com> 
>>> wrote:
>>> 
>>> I am working on a small application where the primary function is to 
>>> display the time to the user.  My hope was to honor the user's preference 
>>> setting.  I am either missing something or honoring the user's preference 
>>> is harder than expected.
>>> 
>>> So, there are two places to set 24 hr time display.
>>> 
>>> 1. Date & Time preference panel
>>> 2. Language & Region preference panel 
>>> 
>>> The cocoa frameworks react differently depending on where you set this.
>>> 
>>> If set by method 1, cocoa frameworks seem unaware of this setting and it 
>>> appears this is cosmetic in that it only affects the display of the clock 
>>> in the NSStatusBar.
>>> 
>>> If set by method 2, cocoa frameworks reflect this and the Date & Time 
>>> setting is disabled noting that the setting has been overridden.
>>> 
>>> So if a user uses method 1, potentially unaware of method 2, how should one 
>>> go about determining the user's intentions.
>>> 
>>> There are deprecated methods using: (didn't try, it's deprecated)
>>>  NSUserDefaults with the key NSShortTimeDateFormatString
>>> 
>>> There are supported methods using: (works with method 2)
>>>  NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 
>>> locale:[NSLocale currentLocale]];
>>>  BOOL is24Hour = ([format rangeOfString:@"a"].location == NSNotFound);
>>> 
>>> Can anyone provide any clarity here?
>>> 
>>> Sandor


___

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: 12 hr vs 24 hr time display

2017-01-03 Thread Steve Christensen
In the Date & Time preference panel, I assume that you're referring to the 
option on the Clock tab. If so, those settings refer only to the menubar clock 
display.

If you notice in that same preference panel, on the Date & Time tab, there is a 
message at the bottom that says, "To set date and time formats, use the 
Language & Region preferences." Clicking the button takes you to that other 
panel, and there you will find a checkbox that lets you select 24-hour time.

The Language & Region settings are what specify the locale that is used for 
formatting date and time values (among other things), which is why you see 
those changes reflected in the NSDateFormatter methods.


> On Jan 2, 2017, at 10:16 PM, Sandor Szatmari  
> wrote:
> 
> I am working on a small application where the primary function is to display 
> the time to the user.  My hope was to honor the user's preference setting.  I 
> am either missing something or honoring the user's preference is harder than 
> expected.
> 
> So, there are two places to set 24 hr time display.
> 
> 1. Date & Time preference panel
> 2. Language & Region preference panel 
> 
> The cocoa frameworks react differently depending on where you set this.
> 
> If set by method 1, cocoa frameworks seem unaware of this setting and it 
> appears this is cosmetic in that it only affects the display of the clock in 
> the NSStatusBar.
> 
> If set by method 2, cocoa frameworks reflect this and the Date & Time setting 
> is disabled noting that the setting has been overridden.
> 
> So if a user uses method 1, potentially unaware of method 2, how should one 
> go about determining the user's intentions.
> 
> There are deprecated methods using: (didn't try, it's deprecated)
>NSUserDefaults with the key NSShortTimeDateFormatString
> 
> There are supported methods using: (works with method 2)
>NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 
> locale:[NSLocale currentLocale]];
>BOOL is24Hour = ([format rangeOfString:@"a"].location == NSNotFound);
> 
> Can anyone provide any clarity here?
> 
> Sandor


___

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: Animating autolayout constraint changes for subviews

2016-12-28 Thread Steve Christensen
Sorry, I mostly copied your code and moved things around. Try -setNeedsLayout 
instead of -layoutIfNeeded.


> On Dec 28, 2016, at 9:58 PM, Doug Hill <cocoa...@breaqz.com> wrote:
> 
> Hello Steve,
> 
> FWIW, I’ve tried both ways and it doesn’t seem to affect the problem I’m 
> having. However, Apple says to update constraints than do the animation block 
> with layoutIfNeeded, according to this WWDC session:
> 
> https://developer.apple.com/videos/play/wwdc2012/228/?id=228 
> <https://developer.apple.com/devcenter/download.action?path=/videos/wwdc_2012__sd/session_228__best_practices_for_mastering_auto_layout.mov>
> 
> But in general, the SDK documentation on animating autolayout constraint 
> changes is borderline non-existent. 
> 
> Doug Hill
> 
> 
>> On Dec 28, 2016, at 5:54 PM, Steve Christensen <puns...@mac.com 
>> <mailto:puns...@mac.com>> wrote:
>> 
>> I have always put the thing that I'm animating into the animation block:
>> 
>> - (IBAction)animateIt:(id)sender
>> {
>>  static BOOL small = NO;
>> 
>>  small = !small;
>> 
>>  CGFloat newWidth = small ? self.view.frame.size.width / 2 : 
>> self.view.frame.size.width;
>> 
>>  [UIView animateWithDuration:1 animations:
>>  ^{
>>  self.containerWidthConstraint.constant = newWidth;
>>  [self.view layoutIfNeeded];
>>  }];
>> }
>> 
>>> On Dec 28, 2016, at 4:14 PM, Doug Hill <cocoa...@breaqz.com 
>>> <mailto:cocoa...@breaqz.com>> wrote:
>>> 
>>> Hi Ken,
>>> 
>>> I uploaded a sample project here:
>>> 
>>> https://github.com/djfitz/TestAutolayoutAnimations 
>>> <https://github.com/djfitz/TestAutolayoutAnimations>
>>> 
>>> I tried to strip this down to what is needed to show the behavior I see.
>>> 
>>> My code to actually do the animation is this:
>>> 
>>> - (IBAction)animateIt:(id)sender
>>> {
>>> static BOOL small = NO;
>>> 
>>> if( small )
>>> {
>>> [self.view layoutIfNeeded];
>>> 
>>> self.containerWidthConstraint.constant = 
>>> self.view.frame.size.width;
>>> 
>>> [UIView animateWithDuration:1 animations:
>>> ^{
>>> [self.view layoutIfNeeded];
>>> }];
>>> }
>>> else
>>> {
>>> [self.view layoutIfNeeded];
>>> 
>>> self.containerWidthConstraint.constant = 
>>> self.view.frame.size.width / 2;
>>> 
>>> [UIView animateWithDuration:1 animations:
>>> ^{
>>> [self.view layoutIfNeeded];
>>> }];
>>> }
>>> 
>>> small = !small;
>>> }
>>> 
>>> 'container view' has one subview which is a UILabel. The label is pinned to 
>>> the superview edges via autolayout constraints. (e.g. trailing, leading, 
>>> top, bottom edges all pinned to superview edges.)
>>> 
>>> I tried a few different variations, including leaving out the first 
>>> layoutIfNeeded (which some people say should be done, others not).
>>> 
>>> The exact behavior is that the label will resize to the new size 
>>> immediately and reflow the text, then the container view will animate it's 
>>> size change. It would be nice if both the label and the container view 
>>> animate at the same time.
>>> Also, as I mentioned, a button will exhibit the same behavior, probably 
>>> because it has a UILabel inside it to show the button text.
>>> 
>>> Thanks again for any ideas.
>>> 
>>> Doug Hill
>>> 
>>> 
>>>> On Dec 28, 2016, at 12:50 PM, Ken Thomases <k...@codeweavers.com> wrote:
>>>> 
>>>> On Dec 28, 2016, at 1:55 PM, Doug Hill <cocoa...@breaqz.com> wrote:
>>>>> 
>>>>> I can now animate my constraint changes but I notice that subviews aren't 
>>>>> animated. For example, I have a single view with a width constraint, and 
>>>>> this view has a label as a subview that expands to the size of it's 
>>>>> parent view via edge constraints.
>>>>> I can change the width constraint constant of the parent view at runtime 
>>>>> and it animates very well. However, the subviews jump into place 
>>>>> immediately then the parent view animates into place. I see the same 
>>>>> behavior with a button as a subview.
>>>> 
>>>> Show exactly how you're animating the constraint changes.  Are you really 
>>>> animating the change of the constraint or are you doing a layoutIfNeeded 
>>>> within an animation context?  Even if the former, are you calling any 
>>>> methods that force layout (layoutIfNeeded or similar)?  If so, where/when?
>>>> 
>>>> 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: Animating autolayout constraint changes for subviews

2016-12-28 Thread Steve Christensen
I have always put the thing that I'm animating into the animation block:

- (IBAction)animateIt:(id)sender
{
static BOOL small = NO;

small = !small;

CGFloat newWidth = small ? self.view.frame.size.width / 2 : 
self.view.frame.size.width;

[UIView animateWithDuration:1 animations:
^{
self.containerWidthConstraint.constant = newWidth;
[self.view layoutIfNeeded];
}];
}

> On Dec 28, 2016, at 4:14 PM, Doug Hill  wrote:
> 
> Hi Ken,
> 
> I uploaded a sample project here:
> 
> https://github.com/djfitz/TestAutolayoutAnimations
> 
> I tried to strip this down to what is needed to show the behavior I see.
> 
> My code to actually do the animation is this:
> 
> - (IBAction)animateIt:(id)sender
> {
>   static BOOL small = NO;
> 
>   if( small )
>   {
>   [self.view layoutIfNeeded];
> 
>   self.containerWidthConstraint.constant = 
> self.view.frame.size.width;
> 
>   [UIView animateWithDuration:1 animations:
>   ^{
>   [self.view layoutIfNeeded];
>   }];
>   }
>   else
>   {
>   [self.view layoutIfNeeded];
> 
>   self.containerWidthConstraint.constant = 
> self.view.frame.size.width / 2;
> 
>   [UIView animateWithDuration:1 animations:
>   ^{
>   [self.view layoutIfNeeded];
>   }];
>   }
> 
>   small = !small;
> }
> 
> 'container view' has one subview which is a UILabel. The label is pinned to 
> the superview edges via autolayout constraints. (e.g. trailing, leading, top, 
> bottom edges all pinned to superview edges.)
> 
> I tried a few different variations, including leaving out the first 
> layoutIfNeeded (which some people say should be done, others not).
> 
> The exact behavior is that the label will resize to the new size immediately 
> and reflow the text, then the container view will animate it's size change. 
> It would be nice if both the label and the container view animate at the same 
> time.
> Also, as I mentioned, a button will exhibit the same behavior, probably 
> because it has a UILabel inside it to show the button text.
> 
> Thanks again for any ideas.
> 
> Doug Hill
> 
> 
>> On Dec 28, 2016, at 12:50 PM, Ken Thomases  wrote:
>> 
>> On Dec 28, 2016, at 1:55 PM, Doug Hill  wrote:
>>> 
>>> I can now animate my constraint changes but I notice that subviews aren't 
>>> animated. For example, I have a single view with a width constraint, and 
>>> this view has a label as a subview that expands to the size of it's parent 
>>> view via edge constraints.
>>> I can change the width constraint constant of the parent view at runtime 
>>> and it animates very well. However, the subviews jump into place 
>>> immediately then the parent view animates into place. I see the same 
>>> behavior with a button as a subview.
>> 
>> Show exactly how you're animating the constraint changes.  Are you really 
>> animating the change of the constraint or are you doing a layoutIfNeeded 
>> within an animation context?  Even if the former, are you calling any 
>> methods that force layout (layoutIfNeeded or similar)?  If so, where/when?
>> 
>> 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: iOS: Preventing a singleton from being deallocated when the app is in the background.

2016-10-19 Thread Steve Christensen
The only difference between your code and mine is that you haven't initialized 
onceToken = 0 so it has a random value.

I looked around to see if that makes a difference and didn't get much 
confirmation one way or another. One by Mike Ash 
(https://www.mikeash.com/pyblog/friday-qa-2014-06-06-secrets-of-dispatch_once.html)
 mentions, "Note that dispatch_once_t is just a typedef for long, initialized 
to zero, and with the meaning of other values left up to the implementation."

It's a simple thing to change to see what happens.


> On Oct 19, 2016, at 12:54 PM, Alex Zavatone <z...@mac.com> wrote:
> 
> On Oct 19, 2016, at 2:08 PM, Steve Christensen wrote:
> 
>> This is the model I use for singletons and I've never had the singleton 
>> instance deallocated out from under me.
>> 
>> + (MyClass*) sharedThing
>> {
>>  static dispatch_once_t sOnceToken = 0;
>>  static MyClass* sSharedThing = nil;
>> 
>>  dispatch_once(,
>>  ^{
>>  sSharedThing = [[MyClass alloc] init];
>>  });
>> 
>>  return sSharedThing;
>> }
>> 
> 
> It appears that this is what I am doing.  Though the details are not the 
> same, should this matter?
> 
> We have already had to patch one instance where the ref to this was getting 
> lost 
> 
> + (instancetype)referenceGeofenceController {
>   static GeofenceControllerSingleton *geofenceController;
>   static dispatch_once_t onceToken;
> 
>   dispatch_once(, ^{
>   geofenceController = [[self alloc] init];
>   });
>   return geofenceController;
> }
> 
> 
> Is there anything wrong with what I'm doing?  should I be using 
> [GeofenceControllerSingleton alloc] init] instead of [[self alloc] init]?
> 
> Thanks a million.  
> Alex Zavatone
> 
>>> On Oct 19, 2016, at 11:41 AM, Alex Zavatone <z...@mac.com> wrote:
>>> 
>>> We are running into what appears to be a case where a singleton that has 
>>> been created through GCD dispatch_once may be getting deallocated by the OS.
>>> 
>>> To check and see if this is the case, I have put logging code in the 
>>> dealloc method, but our logs do show the init method being called twice 
>>> even though the method is past the dispatch_once.
>>> 
>>> I'm interested in seeing if I can prevent the singleton from being 
>>> deallocated.
>>> 
>>> I have seen on discussion where people suggest keeping a private strong 
>>> property in the singleton with a reference to self to prevent this from 
>>> happening.
>>> 
>>> Something like 
>>>  self.selfReference = self;
>>> 
>>> within an interface extension.
>>> 
>>> Naturally, this is raising some eyebrows with other members of the team, 
>>> but currently, no one has a solution to make sure that this core singleton 
>>> doesn't get deallocated when the app is in the background and has been 
>>> running for a while.
>>> 
>>> Does this sound sane or a horrible idea?
>>> 
>>> If it does sound like a horrible idea, how would you suggest preventing an 
>>> important singleton from being deallocated?
>>> 
>>> Thanks in advance,
>>> Alex Zavatone


___

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: Preventing a singleton from being deallocated when the app is in the background.

2016-10-19 Thread Steve Christensen
This is the model I use for singletons and I've never had the singleton 
instance deallocated out from under me.

+ (MyClass*) sharedThing
{
static dispatch_once_t sOnceToken = 0;
static MyClass* sSharedThing = nil;

dispatch_once(,
^{
sSharedThing = [[MyClass alloc] init];
});

return sSharedThing;
}



> On Oct 19, 2016, at 11:41 AM, Alex Zavatone  wrote:
> 
> We are running into what appears to be a case where a singleton that has been 
> created through GCD dispatch_once may be getting deallocated by the OS.
> 
> To check and see if this is the case, I have put logging code in the dealloc 
> method, but our logs do show the init method being called twice even though 
> the method is past the dispatch_once.
> 
> I'm interested in seeing if I can prevent the singleton from being 
> deallocated.
> 
> I have seen on discussion where people suggest keeping a private strong 
> property in the singleton with a reference to self to prevent this from 
> happening.
> 
> Something like 
>self.selfReference = self;
> 
> within an interface extension.
> 
> Naturally, this is raising some eyebrows with other members of the team, but 
> currently, no one has a solution to make sure that this core singleton 
> doesn't get deallocated when the app is in the background and has been 
> running for a while.
> 
> Does this sound sane or a horrible idea?
> 
> If it does sound like a horrible idea, how would you suggest preventing an 
> important singleton from being deallocated?
> 
> Thanks in advance,
> Alex Zavatone


___

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: SecStaticCodeCheckValidity fails when app is lauched from Terminal

2016-09-26 Thread Steve Christensen
What is the error code when it fails?


> On Sep 26, 2016, at 2:44 AM, Markus Spoettl  wrote:
> 
> I'm using SecStaticCodeCheckValidity() to self check the signature of my own 
> app when it is launched. This works fine and always has.
> 
> All of a sudden, the call to SecStaticCodeCheckValidity() fails if (and only 
> if the application) is started from the Terminal. When I start the very same 
> app from the Dock or from the Finder the check succeeds (iow. the call 
> returns noErr).
> 
> I don't know exactly when it started failing. I only know it definitely 
> worked before on previous versions of El Capitan but now it no longer does (v 
> 10.11.6).
> 
> Any ideas?
> 
> Regards
> Markus


___

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: Core Graphics: Is it better to up-sample or down-sample images when drawing into a rect?

2016-08-25 Thread Steve Christensen
> On Aug 24, 2016, at 8:37 PM, Jeff Szuhay  wrote:
> 
> 
>> On Aug 24, 2016, at 8:02 PM, Britt Durbrow 
>>  wrote:
>> 
>> 
>>> On Aug 24, 2016, at 12:59 PM, Jeff Szuhay  wrote:
>>> 
>>> I draw my images (clocks) into a “reference” sized rectangle—for simplified 
>>> position calculations—and then have CoreGraphics scale into the destination 
>>> view rect.
>> 
>> Don’t do that with bitmap scaling. It’s wasteful, and will look bad.
>> 
>> Instead, create the bitmap at the correct size for it’s destination; and use 
>> the drawing matrix transform functions (scale, translate, rotate, etc) to 
>> set up your drawing environment.
> 
> 
> Okay, so when the user changes the clock size (it’s destination), then 
> recreate the bitmap to the new size and redraw everything at the new scale?

Yep. That way you get the best-quality image since it's built to fit an 
explicit size.

And if parts of your display are cacheable, e.g., the clock background, then 
you can recreate them at that point. Keep an ivar with the size of the view 
when the image(s) were last cached and compare it against the view's current 
size.


___

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: specifying UIInterfaceOrientationMask

2016-07-12 Thread Steve Christensen
So, (UIInterfaceOrientationMask.Portrait | 
UIInterfaceOrientationMask.LandscapeLeft) doesn't work?


> On Jul 12, 2016, at 11:25 AM, William Squires  wrote:
> 
> In iOS 8, I would (in a view controller):
> 
> ...
> override func supportedInterfaceOrientations() -> Int
> {
> return Int(UIInterfaceOrientationMask.Portrait.rawValue) | 
> Int(UIInterfaceOrientationMask.LandscapeLeft.rawValue)
> }
> ...
> 
> but this no longer works in iOS 9, as the method signature is now:
> 
> func supportedInterfaceOrientations() -> UIInterfaceOrientationMask
> 
> instead. So how do I cast the Int result above to a 
> UIInterfaceOrientationMask? I tried the obvious:
> 
> return 
> UIInterfaceOrientationMask(Int(UIInterfaceOrientationMask.Portrait.rawValue) 
> | Int(UIInterfaceOrientationMask.LandscapeLeft.rawValue))
> 
> but Xcode complains that UIInterfaceOrientationMask doesn't have an 
> initializer that takes "Int".
> 
> so what dumb Swift feature am I overlooking now?


___

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: unicode fraction symbol in a NSTextView

2016-06-22 Thread Steve Christensen
Where are you specifying the text encoding of the HTML "document" passed to 
NSMutableAttributedString(HTML:, documentAttributes:)? The default encoding for 
HTML used to be ISO-8859-1, not UTF-8, for HTML 4 and earlier (and could 
continue to be interpreted that way by NSAttributedString for compatibility). 
That could explain the extra character being displayed since the string you're 
passing as the HTML parameter to NSMutableAttributedString doesn't include, for 
example, a charset="utf8" meta tag in its  that would specify the desired 
encoding.

And, unless you're doing some extra formatting not shown in your code snippet, 
is there any reason you wouldn't be initializing ats with 
NSAttributedString(string:s)?


> On Jun 22, 2016, at 9:32 AM, tridiak  wrote:
> 
> I am setting some text to a NSTextView which includes the ‘½’ character. 
> 
> s = name + “ CR "
> switch (CR) {
>   case 0.5:
>   s=s+”½” // \u{00bd}
>   case 0.33:
>   s=s+"⅓"
>   case 0.25:
>   s=s+"¼"
>   case 0.2:
>   s=s+"⅕"
>   case 0.17:
>   s=s+"⅙"
>   case 0.14:
>   s=s+"⅐"
>   case 0.13:
>   s=s+"⅛"
>   default:
>   if CR<1 {s=s+String(format:"%.1f", CR)}
>   else {s=s+String(format:"%.0f", CR)}
>   }
> s=s+"\n”
> 
> let d : NSData = s.dataUsingEncoding(NSUTF8StringEncoding)!
> let ats : NSMutableAttributedString = NSMutableAttributedString(HTML: d, 
> documentAttributes: nil)!
> self.blab.textStorage?.setAttributedString(ats)
> 
> 
> What I see is 'Aasimar CR ½’ instead of 'Aasimar CR ½’.
> Where is the ‘Â' coming from?
> Is it the font or some swift-obj-C confusion?


___

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: debugging AirDrop (update)

2016-05-27 Thread Steve Christensen
I haven't worked with AirDrop, but I just looked at the docs and one of the 
delegate methods is -sharingService:didFailToShareItems:error:. Maybe if you 
implement that you can at least see what the specific error is?

Steve


> On May 26, 2016, at 10:23 PM, Gerriet M. Denkmann  
> wrote:
> 
> I have an OS X app (10.11.5) which has a button called AirDrop, which does:
> 
> - (IBAction)airDrop: (NSButton *)sender   
> {
>   NSArray *shareItems = list of one or more urls of pdf files
>   NSSharingService *service = [ NSSharingService sharingServiceNamed: 
> NSSharingServiceNameSendViaAirDrop];
>   service.delegate = self;//  probably not needed
>   [service performWithItems:shareItems];
> }
> 
> Usually this just works:
> I click the AirDrop button, a Panel slides down with a picture of the pdf (or 
> a symbol for multiple files if more than one).
> I grab my iPad (which has “AirDrop: Contacts Only" set) and unlock it.
> The AirDrop panel on the Mac shows (after a few seconds) my Mac Login 
> picture, I click it, and all is well.
> 
> Sometimes it does not work correctly:
> In this case I have to set the iPad to “AirDrop: Everyone". A generic user 
> picture will appear on the Mac and it will still work.
> 
> But sometimes it does not work at all: 
> I can do whatever (like restarting the iPad; restarting the Mac) but still no 
> picture of a recipient will appear in the Mac AirDrop Panel. 
> 
> How can I debug this?
> 
> Gerriet.
> 
> Found some log messages, which seem to be related:
> 
> Clicking my AirDrop button:
> 
> 27/05/2016 12:17:41.630 sharingd[17313]: 12:17:41.629 : Bonjour discovery 
> started
> 27/05/2016 12:17:41.662 sharingd[17313]: 12:17:41.662 : BTLE advertiser 
> Powered On
> 27/05/2016 12:17:41.664 sharingd[17313]: 12:17:41.663 : BTLE advertising 
> hashes <01ca38ce b5742b51 4900>
> 27/05/2016 12:17:41.667 sharingd[17313]: 12:17:41.666 : 
> SDBonjourBrowser::failedToStartAdvertisingWithError Error 
> Domain=NSMachErrorDomain Code=8 "(os/kern) no access" 
> UserInfo={NSLocalizedDescription=wirelessproxd can't start advertising at 
> this time.}
> 27/05/2016 12:17:43.720 sharingd[17313]: 12:17:43.719 : 
> SDBonjourBrowser::failedToStartAdvertisingWithError Error 
> Domain=NSMachErrorDomain Code=8 "(os/kern) no access" 
> UserInfo={NSLocalizedDescription=wirelessproxd can't start advertising at 
> this time.}
> 
> Clicking “Cancel" in the AirDrop Panel:
> 
> 27/05/2016 12:19:46.595 AirDrop[17426]: Error in 
> CoreDragRemoveTrackingHandler: -1856
> 27/05/2016 12:19:46.595 AirDrop[17426]: Error in 
> CoreDragRemoveReceiveHandler: -1856
> 27/05/2016 12:19:46.658 sharingd[17313]: 12:19:46.657 : Bonjour discovery 
> stopped
> 27/05/2016 12:19:46.671 sharingd[17313]: 12:19:46.671 : BTLE advertising 
> stopped
> 
> But still don’t know what to do.
> 
> 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: auto-layout and rotated UILabels

2016-02-06 Thread Steve Christensen
On Feb 4, 2016, at 2:59 PM, Quincey Morris 
<quinceymor...@rivergatesoftware.com> wrote:
> 
> On Feb 4, 2016, at 13:01 , Steve Christensen <puns...@mac.com 
> <mailto:puns...@mac.com>> wrote:
>> 
>> it looks like the width of the embedding view is set to the text width of 
>> the UILabel instead of the text height, which is borne out by the view 
>> geometry
> 
> Can you use a custom class for the embedding view and override its 
> ‘intrinsicContentSize’ property to return the inner view’s height and width 
> reversed?

Quincey: Thanks for a starting point.

I spent this afternoon playing around with it some more. Overriding 
-intrinsicContentSize does result in a correctly sized bounds, but the frame is 
still invalid and the view contents are still drawn incorrectly.

I finally found a simple solution that avoids all the headache of trying to get 
auto layout to play nicely with a transformed UILabel: I don't apply a 
transform to the UILabel. Instead I subclass UILabel and override two of its 
methods: -textRectForBounds:limitedToNumberOfLines: (which 
-intrinsicContentSize calls) and -drawTextInRect:.


- (CGRect) textRectForBounds:(CGRect)bounds 
limitedToNumberOfLines:(NSInteger)numberOfLines
{
CGRect  textRect = [super textRectForBounds:bounds 
limitedToNumberOfLines:numberOfLines];

return CGRectMake(textRect.origin.y, textRect.origin.x, 
textRect.size.height, textRect.size.width);
}

- (void) drawTextInRect:(CGRect)rect
{
CGContextRefcontext = UIGraphicsGetCurrentContext();
CGRect  bounds  = self.bounds;
CGFloat translateX  = bounds.size.width / 2;
CGFloat translateY  = bounds.size.height / 2;
CGAffineTransform   transform   = CGAffineTransformIdentity;

transform = CGAffineTransformTranslate(transform, translateX, 
translateY);
transform = CGAffineTransformRotate(transform, (CGFloat)-M_PI_2);
transform = CGAffineTransformTranslate(transform, -translateX, 
-translateY);

CGContextSaveGState(context);
CGContextConcatCTM(context, transform);

rect = CGRectApplyAffineTransform(rect, transform);
[super drawTextInRect:rect];

CGContextRestoreGState(context);
}

___

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

auto-layout and rotated UILabels

2016-02-04 Thread Steve Christensen
Our UI design calls for a UILabel rotated 90° CCW. When I originally started 
implementing several months ago, I tried going the auto-layout route but ran 
out of time without a solution, so I went back to manual layout, calculating 
the size of the label in code then adjusting the frames of the label and 
adjacent views.

I'm now trying another shot at moving to auto-layout but am still having 
issues. There doesn't seem to be a lot of information on handling auto-layout 
and transformed views, but one thing I came across was to try embedding a 
transformed view in a non-transformed view and then applying peer and superview 
constraints to the embedding view. I did that, but it looks like the width of 
the embedding view is set to the text width of the UILabel instead of the text 
height, which is borne out by the view geometry.

(lldb) po _label
>

(lldb) print (CGRect)[_label bounds]
(CGRect) $0 = (origin = (x = 0, y = 0), size = (width = 141.5, height = 595))

(lldb) po _label.superview
>


And here's a screenshot so you can see the current state of things. I set the 
background on the embedding view to blue and the label's background to red for 
visibility.

https://www.dropbox.com/s/yb3xem9ii36rris/rotated-uilabel.jpg?dl=0


Ideally there's an all auto-layout solution but I have no clue. At this point 
I'd be happy if all I had to do was to calculate and set the rotated bounds of 
the label and then have auto-layout go from there but I'm not even sure what I 
need to do to make that happen. Does anyone have experience trying to do 
something like this? The app is running on iOS 8 and later, if that helps.

Thanks,
Steve


___

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

UIActivityViewController > Mail: some elements picking up custom window tint color

2015-09-26 Thread Steve Christensen
My app sets a custom tint color on the main window as part of its 
initialization.

Later it creates a UIActivityViewController instance and explicitly set its 
controller.view's tint color to the blue system tint color before having the 
root view controller present it. I added this last piece in the iOS 7 or 8 
timeframe when I noticed that buttons were appearing in the custom tint color, 
and it's been working fine. Running on iOS 9.0.1, I noticed that the custom 
tint is popping up again. Here's what I'm doing and seeing:

• When the activity selector is presented then the Cancel button is system blue.

• When I select Mail as the activity, the message composer's Cancel button is 
displayed in the custom tint color while the view is animating in, then changes 
to blue.

• When I tap on the To: field, the caret and + button appear, displayed in the 
custom tint color. (If I choose Message as the activity then I see the same 
thing there as well.)

• When I tap the Cancel button for the message then in the confirmation alert, 
the Save Draft and Cancel buttons are displayed in the custom tint and the 
Delete Draft button is displayed in its expected red.

Am I missing something?


___

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: Help understanding Apple's approach in documentation a little better.

2015-08-17 Thread Steve Christensen
On Aug 16, 2015, at 2:58 PM, Alex Zavatone z...@mac.com wrote:

 Would be REALLY nice if there was something visual that simply communicated 
 to you that they are not for public consumption.
 
 If I see it in the left pane of the debugger, and no visual indicators are 
 stating that it's restricted, It's telling us that it's available - unless we 
 spend the time to look up the internals for everything that's displayed in 
 the variables pane that exposes an object instanced from a framework class.
 
 I know it's too simplistic to assume that a color change would be enough and 
 appropriate to indicate to the programmer that you can see there, but you 
 really don't have access to them, but SOME sort of treatment to the private 
 data would be really nice when displaying it, so that it's painfully obvious 
 to the developer that it's private freaking data.
 
 The developer should just have to look and instantly see that it's data 
 that's used behind the scenes and they can't play with it.
 
 If the debugger's variable pane exposes it, it's misleading if it doesn't 
 somehow indicate that it's not for the developer to access.
 
 At the least, it's confusing, because the docs say it's not supposed to be 
 there, yet there it is.  

No, both the headers and docs communicate what's public and what's not; the 
debugger's variable panel exposes all the properties, public or not. AFAIK 
there's no Obj-C ivar/property/method runtime attribute that marks that item as 
public or private, thus the debugger has no means of determining such.

As has been mentioned previously, that useful (to you) private methods exist is 
an implementation detail subject to change in a future OS release. That may 
have been the best way to implement class functionality at the time, but since 
the method isn't in the public header or documentation, Apple is free to remove 
any or all of those private methods at any time or, more problematically, 
change the behavior of those methods. You can test for the former but not for 
the latter so you'd have to keep testing your app on every dot-release.

Think about this from your own point of view: If you released a framework for 
developers to use, would you leave in all of your private methods forever even 
if you made radical internal changes, just so that you didn't break a developer 
who used one of them?


___

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

debugging UIWebView and audio errors

2015-07-30 Thread Steve Christensen
Does anybody know if there's a way to get WebKit to dump errors to the console? 
The default behavior appears to be to fail silently.

Background:

I'm working on an app that deploys to iOS 7 and later. It contains a UIWebView 
whose content is build dynamically and contains, among other things, a number 
of audio tags that the user can tap on to play local or remote audio files. 
I'm finding that local audio files play just fine, but remote files don't. If I 
put the HTML into a file and open it in Safari or Chrome then both audio items 
load and play just fine so it isn't an issue of not being able to locate the 
remote file, or that the remote file contains bad data.

I created a simplified test that uses the same audio file, just that one copy 
is on the server, so that I can be working with the same audio data. On iOS 7 
the control for the remote file initially shows the play button but then 
shortly thereafter changes to display Cannot play audio file.; on iOS 8 it 
just displays Loading.

While I was at it, I installed Javascript event listeners on both of the 
audio tags so I could watch state changes. The local file fires 
loadstart-progress-suspend-loadedmetadata, and the remote one only loadstart 
and Loading remains visible in the control so it appears that the loading 
process is getting hung up or aborted for some reason.

Thoughts?


___

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 version check

2015-06-12 Thread Steve Christensen
I hadn't seen the NSProcessInfo method before so I took a peek at the header 
and noticed that it's available as of iOS 8:

- (BOOL) isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version 
NS_AVAILABLE(10_10, 8_0);

If your app still needs to run on iOS 7 then using the UIDevice method may be a 
better way to go.


 On Jun 12, 2015, at 10:04 AM, Quincey Morris 
 quinceymor...@rivergatesoftware.com wrote:
 
 On Jun 12, 2015, at 06:22 , Steve Christensen puns...@mac.com wrote:
 
 NSInteger majorSystemVersion = 
 UIDevice.mainDevice.systemVersion.integerValue;
 
 
 On Jun 12, 2015, at 08:11 , David Brittain websi...@paperetto.com wrote:
 
 You can use NSProcessInfo isOperatingSystemAtLeastVersion
 
 Thanks for the suggestions. I think I’ll use NSProcessInfo because it’s 
 already in numeric form.


___

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 version check

2015-06-12 Thread Steve Christensen
How about something like this?

NSInteger majorSystemVersion = UIDevice.mainDevice.systemVersion.integerValue;

if (majorSystemValue == 8)
AVSpeechUtterance.rate = the wrong value that used to work
else
AVSpeechUtterance.rate = the right value


 On Jun 11, 2015, at 10:23 PM, Quincey Morris 
 quinceymor...@rivergatesoftware.com wrote:
 
 There’s a particular API that’s broken in iOS 8 (AVSpeechUtterance.rate), but 
 not broken in iOS 7, and fixed in iOS 9. Using Xcode 7, therefore, I get the 
 iOS 9 simulator, which means different speech behavior running in the 
 simulator from running on an actual device (still running 8.3).
 
 So I’m looking for a version check that will allow me to set the property 
 based on the running iOS version, something like this:
 
 if (floor(NSFoundationVersionNumber) = NSFoundationVersionNumber_iOS_8_0  
 floor (NSFoundationVersionNumber)  NSFoundationVersionNumber_iOS_9_0)
  AVSpeechUtterance.rate = the wrong value that used to work
 else
  AVSpeechUtterance.rate = the right value
 
 but there’s no definition of NSFoundationVersionNumber_iOS_9_0 in the iOS 9 
 SDK. In fact, there’s nothing higher than NSFoundationVersionNumber_iOS_8_1 
 in the iOS 9 SDK. That means there’s no definition that lets me test against 
 8.2, 8.3 or 8.4.
 
 I’m confused about what to do here. The iOS 8.3 SDK itself has no 
 NSFoundationVersionNumber_iOS_8_x definitions at all, so going back to Xcode 
 6 wouldn't solve the problem, except that the simulator would be 8.x, so the 
 problem wouldn’t show up again until iOS 9 is released.
 
 I must be missing something really obvious here.
 
 (The app’s deployment target is currently set to 8.1, but I don’t think that 
 makes any difference, except that I don’t care about iOS 7, which is 
 unfortunately the one version I *could* check for.)


___

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: Using CFSTR() with const char * variable

2015-06-06 Thread Steve Christensen
In my prefix file that is used to build precompiled headers, I include the 
following after #import-ing all the framework headers. It replaces the standard 
definition with a version that doesn't insert quotes around an unquoted string 
literal.

#undef CFSTR//(cStr)
#ifdef __CONSTANT_CFSTRINGS__
#define CFSTR(cStr)  ((CFStringRef) 
__builtin___CFStringMakeConstantString(cStr))
#else
#define CFSTR(cStr)  __CFStringMakeConstantString(cStr)
#endif



 On Jun 5, 2015, at 8:02 PM, Carl Hoefs newsli...@autonomy.caltech.edu wrote:
 
 If I use CFSTR() in the following way:
CFStringRef mystr = CFSTR( This is a string );
 there is no problem.
 
 However, if I use a variable instead of “string” Xcode flags this as an error:
const char *mystring = This is a string;
CFStringRef mystr = CFSTR( mystring );
   ^   — Expected )
 
 In CFString.h, CFSTR is defined as:
#define CFSTR(cStr)  __CFStringMakeConstantString( cStr )
 
 Is it possible to use CFSTR() with a const char * variable?
 
 Xcode 6.3.2
 -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: Looking at self = [super init].

2015-05-31 Thread Steve Christensen
No, it doesn't make a difference. In both cases the compiler will generate a 
test and branch to the method's epilogue. For the = case:

if (self = [super init]) ...

is equivalent to:

if ((self = [super init]) != nil) ...

is equivalent to:

self = [super init];
if (self) ...

is equivalent to:

self = [super init];
if (self != nil) …

They all:

• Call the superclass' -init method.
• Store the result in self.
• Test if self is not equal to nil/zero.
• Branch to method epilogue (or at least past {...}) if not.

The == case that has been mentioned just omits the second step because self 
isn't modified by calling [super init]. And the equivalent statements for the 
other case (! / ==) do the same thing except that the test step is the inverse.

In my opinion having a macro to replace the self = [super init] idiom saves 
you a couple of seconds of typing — once; it obfuscates behavior since you need 
to locate the macro to see what it does if you forget; and it is applicable 
only to subclasses where you're calling a superclass' -init method. It doesn't 
help for, e.g., -initWithCoder:, -initWithFrame:, etc., which then means you 
need to come up with a bunch of other macros to handle those cases or you're 
special-casing [super init].

Choosing to do an early return or not is up to you. Personally I prefer the if 
(self != nil) {...} case, even if the method is long so that I can see 
structure. To say more risks getting into a religious discussion that nobody 
wins. :)


 On May 30, 2015, at 3:20 PM, Alex Zavatone z...@mac.com wrote:
 
 Actually, i was typing by habit and included == instead of = by mistake.
 
 So, while you answered the question, you may have answered the wrong question.
 
 The question is not for
 
 if ( self == [super init])
 
 It's 
 
 if ( self =  [super init])
 
 How does that change your answer?
 
 On May 30, 2015, at 6:08 PM, Michael David Crawford wrote:
 
 While in principle machine code implementations of subroutines can
 return from several different places, in practice they don't.  Rather
 the compiler's code generator emits a branch instruction to the end of
 the subroutine, there there is an epilog.
 
 There are many good reasons for returning from the middle in certain
 specific cases; what if the only epilog you need is an rts?
 Branching to the epilog could cause a cache miss.
 
 I expect the compiler developers know all about this but don't
 typically avail themselves of it because writing compilers is
 difficult.
 
 To be clear, the following source code:
 
 - (id) init
 {
  if ( self == [super init] ) return nil;
 
  // lots of code goes here
 
  return self;
 }
 
 ... is implemented as something like this, but in machine code:
 
 - (id) init
 {
  id result;
  if ( self == [super init] ){
result = nil;
goto epilog;
  }
 
  // lots of code goes here
  result = self;
 
 epilog:
  return result;
 }
 Michael David Crawford, Consulting Software Engineer
 mdcrawf...@gmail.com
 http://www.warplife.com/mdc/
 
  Available for Software Development in the Portland, Oregon Metropolitan
 Area.
 
 
 On Fri, May 29, 2015 at 6:25 PM, Graham Cox graham@bigpond.com wrote:
 
 On 30 May 2015, at 3:22 am, Alex Zavatone z...@mac.com wrote:
 
 // We don't care if this gets long.
 
 
 My take is that you're rewriting a well-recognised idiom to solve a 
 non-existent problem.
 
 The well-recognised idiom makes it easy to verify it's correct. Hiding a 
 different construct inside a macro obscures that, making it harder to 
 verify the code. It's not wrong exactly, just harder to see at a glance 
 that it's right.
 
 The non-existent problem you're trying to solve is that the gap between a 
 pair of braces could get large. So what? Early returns can be another 
 source of bugs, so structural purists would tell you that you shouldn't do 
 that. Sometimes I think it's justified, but not usually worthwhile. Another 
 religious issue is whether matching braces should line up or not. 
 Personally I prefer that they do, at the cost of an extra line. Because you 
 aren't doing that, your long distance between braces is bothering you, 
 because you're losing track of where it started (I assume that's why it's 
 bothering you). If you line up the braces that is much less of an issue.
 
 Source code is for humans, so it should be as readable as you can possibly 
 make it. Macros often hinder that. Unaligned braces hinder that. Multiple 
 statements per line hinder that.
 
 Factoring code helps, so I'd suggest that's the better way to solve this. 
 (and it's also beneficial when it comes to making sure that -initWithCoder: 
 and other initializers that don't correctly follow the designated 
 initializer rule can get access to your common initialization. While this 
 is rarely a problem, I did notice that the recent change to encourage the 
 use of -initWithCoder: for unpacking NSViews from a nib breaks this 
 long-standing rule and so a common 

Re: Tracking the retain count

2015-05-19 Thread Steve Christensen
I just finished catching up on the discussion and keep coming back to the 
fragile nature of relying on retainCount. For now you do, indeed, have the 
option to vaporize your toes; later you may not have access to a ray gun if 
Apple decides that it's in the best interests of all concerned that they retain 
their toes, not their objects.

I don't know what your app architecture looks like, but was wondering if you 
could build in a supportable method of managing what's in the cache without 
having to do other than a few localized changes.

One thought I had was to base all your cacheable objects on a class whose sole 
function is to notify the cache when the last reference goes away, i.e., when 
dealloc is called. If the cache kept track of all cached objects using a 
NSMapTable with weak references then the cache itself wouldn't affect the 
retain count, so you'd never have to be looking at that. Reads from and writes 
to the NSMapTable would need to be protected for consistency.

Does this sound like it could work?


 On May 19, 2015, at 12:55 AM, Britt Durbrow 
 bdurb...@rattlesnakehillsoftworks.com wrote:
 
 On May 18, 2015, at 8:59 PM, Quincey Morris 
 quinceymor...@rivergatesoftware.com wrote:
 
 Let me try and summarize where we are, in response to the several recent 
 suggestions:
 
 Close, but not quite:
 
 I have several apps which are built on an existing, fully functional data 
 management layer that was originally built for a full desktop virtual-memory 
 environment (FWIW, it pre-dates the existence of Core Data). I now need to 
 move some of this to run under iOS. I also don’t want to make changes to this 
 data management layer that would require widespread changes to my other apps 
 that rely on it.
 
 The objects in question are document model objects; and retrieving them from 
 file storage is indeed non-trivial; and so should be minimized when possible. 
 It is not, however, the end of the world if some of them gets evicted from 
 RAM, and then has to be later reloaded (such is life on iOS).
 
 Because these are document model objects, they must be unique in RAM and in 
 file storage; and maintain their identity across RAM/file-storage 
 transitions. If an object is evicted from RAM, it’s contents are written to 
 it’s file storage first, and then later when it is recreated in RAM those 
 contents are reloaded from the file. I am using the UUID of each object to 
 establish the object’s identity across these transitions. However, the object 
 graph while in RAM references other in-memory objects by pointer, not UUID 
 (changing this basic fact of the system would require wide-spread rewrites of 
 all the applications that use this data management system; and I thusly 
 consider it infeasible).
 
 In addition, because of the overhead of managing the uniqueness of the 
 UUIDs, it’s too expensive to create new objects regularly on demand. The 
 purpose of the cache is to extend the lifetime of otherwise unreferenced 
 objects so that they can be reused rather than reincarnated. It does this by 
 taking ownership of (retaining, keeping a strong reference to, however you 
 want to think of it) every object in the cache.
 
 It’s not maintaining the UUIDs as unique that makes for the expense, it’s the 
 loading and unloading of the document model objects that does so; and to a 
 lesser extent, keeping the object graph coherent. The objects in the system 
 are not interchangeable or reusable; each one must maintain it’s identity 
 even if it’s in-memory pointer address changes over time. The file storage 
 system also enforces this identity by storing and retrieving objects by UUID.
 
 This means that objects can exist in memory in one of these states:
 
 The way I see it, any given object can be in one of these states:
 
 * Not in RAM at all; only in file storage (and stored under it’s UUID)
   
 * In RAM as a fault object. Faults are (like as in Core-Data) proxys for 
 objects in file storage, that reserve RAM for the object, but don’t have any 
 of the object’s contents loaded yet. Because they don’t have any contents, 
 they also don’t store any links to other objects in RAM. When any message is 
 sent to a fault object, it causes the object’s contents to be loaded from 
 file storage, and the class to be swizzled back to it’s actual class (this 
 may in turn cause the creation of other fault objects in RAM for objects that 
 are not in RAM but referenced by the fault’s contents).
 
 * In RAM as a fully “inflated” object. This is a regular Objective-C object, 
 with ivars, pointers, methods, and all the associated stuff.
 
 Additionally, the objects in RAM (fault or inflated) can be in one of these 
 states:
 
 * Referenced. This is as you stated - something has a strong link to it (be 
 it in the graph of document objects, or some other object in the system, or 
 some variable on the stack someplace).
 
 * Unreferenced. Also as you stated… except:
 
 I’m not drawing a distinction 

Re: Tracking the retain count

2015-05-19 Thread Steve Christensen
On May 19, 2015, at 8:52 AM, Britt Durbrow 
bdurb...@rattlesnakehillsoftworks.com wrote:
 
 On May 19, 2015, at 7:20 AM, Steve Christensen puns...@mac.com wrote:
 
 I just finished catching up on the discussion and keep coming back to the 
 fragile nature of relying on retainCount. For now you do, indeed, have the 
 option to vaporize your toes; later you may not have access to a ray gun if 
 Apple decides that it's in the best interests of all concerned that they 
 retain their toes, not their objects.
 
 Restating a previous concern of mine:
 
 However, it’s not actually something that’s likely to get deprecated; and by 
 paying very careful attention to the rules, it should be OK to use in this 
 very narrow circumstance?
 
 If this is wrong - please (hopefully someone from Apple) correct me!
 
 Yes, I am a bit concerned that it could become deprecated. I suppose that I 
 could just override retain and release in that case; and track the retain 
 count myself; although I seriously doubt that that functionality will be 
 deprecated/removed as there’s too much oddball stuff that depends on it… but 
 uggg… that’s nasty. To borrow a phrase from a lolcat, “DO! NOT! WANT!” :-)

I'm not saying that retain/release management would go away entirely, just that 
could be made private to the compiler's management of ARC, for example, if 
Apple decides that ARC, Son of Arc, etc., is the only way to manage object 
lifespan.

 I don't know what your app architecture looks like, but was wondering if you 
 could build in a supportable method of managing what's in the cache without 
 having to do other than a few localized changes.
 
 One thought I had was to base all your cacheable objects on a class whose 
 sole function is to notify the cache when the last reference goes away, 
 i.e., when dealloc is called. If the cache kept track of all cached objects 
 using a NSMapTable with weak references then the cache itself wouldn't 
 affect the retain count, so you'd never have to be looking at that. Reads 
 from and writes to the NSMapTable would need to be protected for consistency.
 
 Does this sound like it could work?
 
 Um… that’s just a weak link? And the only way for an instance to know that 
 it’s got a reference to it outstanding is to override retain and release?

Yes, the cache would be keeping a weak link to each of the in-memory objects it 
manages via a NSMapTable so that it doesn't affect the retain count of the 
current actual users of individual objects. By overriding dealloc in a 
cacheable object base class then you know for a fact that there are no more 
references to the object since that's the only time that dealloc will be 
called. Once that dealloc method notifies the cache to remove the object from 
its NSMapTable then the cache should be in a consistent state.

The other benefit of creating this base class (assuming that you don't already 
have one) is that you don't have to be modifying code all over the place, just 
creating the common dealloc method and modifying the @interface statements in 
some headers so that the objects inherit.
___

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: drawRect runs twice, bounds are changed in between

2015-01-15 Thread Steve Christensen
Would the Managing Live Resize methods of NSView 
(https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/#//apple_ref/doc/uid/2014-SW41)
 be helpful?

The docs for -viewWillStartLiveResize suggest that that would be a good place 
to prepare for a resize instead of trying to manage how has the size changed 
decisions in -drawRect:.


On Jan 14, 2015, at 8:39 PM, N!K pu56ucl...@alumni.purdue.edu wrote:

 On Jan 13, 2015, at 10:50 PM, Jens Alfke j...@mooseyard.com wrote:
 
 
 On Jan 13, 2015, at 9:25 PM, N!K pu56ucl...@alumni.purdue.edu wrote:
 
 A breakpoint at the end of drawRect shows that it runs twice. After the 
 second pass, the view appears, as it should.
 Between passes, bounds is changed somehow, as shown by NSLog  at the start 
 and end of drawRect. 
 Since this will upset code that I will add later, I’d like to stop this. 
 
 The view's being resized, probably as part of view layout. Ideally AppKit 
 shouldn't draw the view before it gets to its final size, but maybe this is 
 part of an animation, or maybe it's something that hasn't been optimized 
 100% in AppKit.
 
 In general, you should not make assumptions about when and how often 
 -drawRect: will be called. That's up to AppKit. Your job is just to draw the 
 view when you’re told to.
 
 OK. Cause is unknown (probably unknowable?) but part of Cocoa. Just because 
 there was only one pass in other projects, I can’t depend on it. drawRect can 
 happen anytime.
 
 You haven't said why the bounds change will upset your code; is the view 
 being changed to the wrong size? That would be an actual problem, but it 
 isn't related to being drawn multiple times. You'd need to look at the view 
 constraints in your window to diagnose that.
 
 —Jens
 
 “Why” takes a little explaining. Thank you for your patience.
 
 I’m trying to learn more about drawing. One stumbling block was getting an 
 NSBezierPath to change size proportional to the window size when the corner 
 is dragged. Per Graham Cox’s suggestion, the view size change can be detected 
 in subsequent passes of drawRect by comparing 
   ratioX = NSWidth ([_path bounds])/NSWidth(bounds);
   ratioY = NSHeight([_path bounds])/NSHeight(bounds);
 with their initial values, which were established in the one pass of drawRect 
 before the view appeared.
 
 This worked perfectly. I used the ratios in 
 -(void)resize{
scaleX = ratioX0/ratioX;
scaleY = ratioY0/ratioY;
NSAffineTransform* tfm = [[NSAffineTransform alloc] init];
[tfm scaleXBy:scaleX yBy:scaleY];
   temp  = [tfm transformBezierPath:_path];
 }
 The initial view was correct. Then dragging the window corner  induced 
 drawRect’s, which detected the changes and scaled the original _path each 
 time; no cumulative errors. The path size tracked the view size correctly. 
 
 
 
 Next I wanted to learn how to scale the whole view in a new project, not just 
 the NSBezierPath. I was  planning to  later include other objects with the 
 NSBezierPath and wanted them to be scaled, too. I used the same 
 initialization and failed because of the bounds change between two passes, 
 which I failed to anticipate. The first pass set the initial values. The 
 second pass detected the change and scaled the view before the view appeared.
 -(void)resize{
scaleX = ratioX0/ratioX;
scaleY = ratioY0/ratioY;
NSAffineTransform* tfm = [[NSAffineTransform alloc] init];
[tfm scaleXBy:scaleX yBy:scaleY];
temp  = [tfm transformBezierPath:_path];
 }
 Thus the path in the initial view was quite different from the initial path, 
 and dragging the corner of the window caused wildly incorrect scaling.
 
 My hope was that there might be a way of suppressing the second pass before 
 display of the view. Now I know better and will figure out another way to 
 initialize and track. Thank you for correcting me.
 
 Nick


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSURLSession delegate not being called in iOS Simulator

2015-01-07 Thread Steve Christensen
An app I'm working on connects to our server with SSL. The production server 
has an SSL certificate but the development server does not. When testing new 
server code on the development server I initialize the NSURLSession with 
[NSURLSession sessionWithConfiguration:delegate:delegateQueue:], passing self 
as the delegate. The class implements 
-URLSession:didReceiveChallenge:completionHandler:, which diddles around to 
allow the connection to proceed without a certificate.

When I build and run the app in the Simulator, calls to -[session 
dataTaskWithRequest:completionHandler:] now complete with an error 
NSURLErrorDomain error -1005 (NSURLErrorNetworkConnectionLost) and the delegate 
method is not being called. The delegate method *does* get called when running 
on a real device.

This has worked fine in the past –both on real devices and in the Simulator– 
and still works fine on real devices running both iOS 7 and 8. I haven't had to 
connect to the development server for a while so the only change I can think of 
in that time is an update to Xcode 6.1.1. Have I missed something?


___

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: Conditional Compilation for 10.9/10.10...

2015-01-02 Thread Steve Christensen
 #if MAC_OS_X_VERSION_MIN_REQUIRED = MAC_OS_X_VERSION_10_9

This is a compile-time conditional so it will be true as long as you are 
building with a pre-10.10 deployment target, thus -constrainScrollPoint: will 
never be compiled in. You should put the #if … #endif around 
-constrainBoundsRect: so that it's available as long as you're deploying to 
10.9.

You could then either implement -constrainBoundsRect: to do one thing and 
-constrainScrollPoint: do something slightly different, or you could calculate 
a newOrigin value based on proposedBounds in -constrainBoundsRect: and pass 
that into -constrainScrollPoint: to do the actual work so that it's handled in 
the method that will be living on into the future.



 On Jan 2, 2015, at 9:35 AM, Peters, Brandon bap...@my.fsu.edu wrote:
 
 Hello,
 
 I am trying set up my application to do some condition compilation to address 
 a deprecated method in 10.9 that has been replaced in 10.10 with another 
 method. I am running Xcode Version 6.2 (6C86e, beta). Here is the code:
 
 #if MAC_OS_X_VERSION_MIN_REQUIRED = MAC_OS_X_VERSION_10_9
 
 -(NSRect)constrainBoundsRect:(NSRect)proposedBounds {
   // code...
 }
 
 #else
 
 -(NSPoint)constrainScrollPoint:(NSPoint)newOrigin {
   // code...
 }
 #endif
 
 In the build settings, I set the target OS and base SDK to 10.10, but the 
 method used in the program was still the first one when it should have been 
 the second one. I figured out that MAC_OS_X_VERSION_MIN_REQUIRED stayed at 
 ‘1090’ regardless of my build settings. Is there a way to set that to 1010? 
 Or is there another way to perform the conditional compilation? Also, I 
 noticed there was no macro MAC_OS_X_VERSION_10_10.


___

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: wits end with nsview and nsrectfill()

2014-11-30 Thread Steve Christensen
Why aren't you creating the subview in -initWithFrame: or in a nib/storyboard? 
The purpose of -drawRect: is solely to [re-]draw the contents of one view, not 
build a view hierarchy. I expect that modifying the view hierarchy while in the 
middle of a drawing cycle is leaving views in an inconsistent state.


 On Nov 30, 2014, at 9:30 AM, Navneet Kumar navnee...@me.com wrote:
 
 I have a custom view in which I am setting the background using NSRectFill() 
 in drawRect:. I am also adding a text field as subview in this method. The 
 textfield is non-selectable, non-editable and is not set to draw background.
 
 When the view comes to front, the background is same, but when it refreshes, 
 the area apart from the text field becomes a bit darker and the text field 
 area shows the original background, this creates a contrast which I want to 
 get rid of.
 
 The view is set to return YES to isOpaque.
 
 I have tried a lot of things but to no avail.
 I have tried CGContext approach to fill rect.
 I also tried setting the color before NSRectFill() to a opaque color as well.
 
 The problem is gone if I removeFromSuperview and create the custom view again 
 and again on each drawRect: of the super view. But this consumes a lot of CPU.
 
 An image showing the contrast is attached herewith.
 
 Please help.
 
 Best,
 Navneet


___

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: Deferred purchase testing in the App Store sandbox?

2014-09-30 Thread Steve Christensen
Thanks, Dave. I took a similar route myself for debug builds, to test that my 
UI was behaving correctly. I just was hoping that there was a more official 
way to test it so that the payment queue was fully in charge.


On Sep 29, 2014, at 2:33 PM, David Brittain websi...@paperetto.com wrote:

 The best I could come up with was to change the build I was testing so
 that on receiving SKPaymentTransactionStatePurchased I store the
 transactions, replace the state with SKPaymentTransactionStateDeferred
 and then
 
  [self performSelector:@selector(deferredPaymentQueue:)
 withObject:_savedTransactions afterDelay:10.0f];
 
 with:
 
 - (void)deferredPaymentQueue:(NSArray *)transactions
 {
 [self paymentQueue:nil updatedTransactions:transactions];
 }
 
 
 This at least proves that my UI behaves the right way in the event of
 SKPaymentTransactionStateDeferred. It's a hack but helped me feel
 somewhat better that the code worked.
 
 Dave
 
 On Mon, Sep 29, 2014 at 12:03 PM, Steve Christensen puns...@mac.com wrote:
 I'm trying to figure out how to test deferred purchases 
 (SKPaymentTransactionStateDeferred) in the sandbox but thus far have not 
 been able to find any guidance. In chatting with The Google I see questions 
 in Apple's developer forums, stack overflow.com, etc., but no answers. Has 
 anybody had success in this area?
 
 Thanks,
 Steve
 
 -- 
 David Brittain
 da...@paperetto.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

Deferred purchase testing in the App Store sandbox?

2014-09-29 Thread Steve Christensen
I'm trying to figure out how to test deferred purchases 
(SKPaymentTransactionStateDeferred) in the sandbox but thus far have not been 
able to find any guidance. In chatting with The Google I see questions in 
Apple's developer forums, stack overflow.com, etc., but no answers. Has anybody 
had success in this area?

Thanks,
Steve


___

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 set UILabel height to even multiple of line height with auto-layout?

2014-09-10 Thread Steve Christensen
That's not the issue I'm having.

Let's say, for example, that label3 contains abcdefghijklmnopqrstuvwxyz; the 
line height for the font 10; and when the label is laid out the label height is 
25. This results in a label that looks like this:

+——+
|abcdefghij|
|klmnopqrst|
|(blank)   |
+——+

The first two lines are visible, but the third line is not drawn because the 
label is not tall enough to completely draw the last line.

My question, below, was trying to determine how I could adjust the label height 
so that it's an even multiple of the font's line height, so in this case the 
label height would be adjusted to 20 (2 x 10) and the text would be drawn like 
this:

+——+
|abcdefghij|
|klmnopqrs…|
+——+


On Sep 9, 2014, at 5:45 PM, Cosmo dennisbi...@gmail.com wrote:

 In my experience, setting a label's numberOfLines property to 1 and its 
 lineBrakeMode property to NSLineBreakByTruncatingTail is all it takes to get 
 text to truncate. You can do it in code, or in IB if you’re laying out your 
 tableViewCell in a storyboard or XIB.
 
 On Sep 9, 2014, at 12:48 PM, Steve Christensen puns...@mac.com wrote:
 
 I have a UITableViewCell with several stacked UILabels:
 
 - label1: set to 1 line, height = single line height, fixed bottom spacing
 - label2: set to 2 lines, height ≥ single line height, fixed bottom spacing
 - label3: set to 0 lines, height ≥ single line height, bottom spacing ≥ min 
 spacing
 
 The layout works in the sense that everything lays out based on the 
 constraints, but if label3's text doesn't entirely fit within the allotted 
 space then I want to see it truncated with an ellipsis. Instead label3's 
 height generally is not an even multiple of its line height so any lines 
 that are not entirely visible just don't get drawn.
 
 I tried overriding -layoutSubviews or -updateConstraints in my 
 UITableViewCell subclass, calling super, then figuring that I could set 
 label3.numberOfLines based on the number of lines that evenly fit into the 
 new value of label3.frame.size.height, but after calling super the height 
 hadn't changed from its initial single-line value.
 
 Are these the right places to do this and I'm just missing some extra work 
 or is there a better way?


___

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

How to set UILabel height to even multiple of line height with auto-layout?

2014-09-09 Thread Steve Christensen
I have a UITableViewCell with several stacked UILabels:

- label1: set to 1 line, height = single line height, fixed bottom spacing
- label2: set to 2 lines, height ≥ single line height, fixed bottom spacing
- label3: set to 0 lines, height ≥ single line height, bottom spacing ≥ min 
spacing

The layout works in the sense that everything lays out based on the 
constraints, but if label3's text doesn't entirely fit within the allotted 
space then I want to see it truncated with an ellipsis. Instead label3's height 
generally is not an even multiple of its line height so any lines that are not 
entirely visible just don't get drawn.

I tried overriding -layoutSubviews or -updateConstraints in my UITableViewCell 
subclass, calling super, then figuring that I could set label3.numberOfLines 
based on the number of lines that evenly fit into the new value of 
label3.frame.size.height, but after calling super the height hadn't changed 
from its initial single-line value.

Are these the right places to do this and I'm just missing some extra work or 
is there a better way?


___

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: rotate UI subview (CFAffline Transform)

2014-07-18 Thread Steve Christensen
On Jul 18, 2014, at 4:51 AM, 2551 2551p...@gmail.com wrote:

 I have a problem which I can't find anyone else asking after hours of 
 searches through stackexchange and the like. 
 
 In a UIView, I'm rotating a subview with a Gesture recognizer that calls this 
 selector:
 
 - (IBAction)rotateShape:(UIRotationGestureRecognizer *)gesture {
gesture.view.transform = CGAffineTransformMakeRotation(gesture.rotation);
 }
 
 The rotation performs as expected and all is right with the world. However, 
 as soon as I attempt to touch or move the rotated subview again (it also has 
 a pan gesture), it reverts to its original orientation.

No, when you apply a transform to a view, it becomes _the_ transform; it isn't 
retaining previous translation state. Based on what you've said, it sounds like 
when you touch/move the object that you're applying a translation transform to 
the view.

 It seems the original transform values are still being retained and held by 
 the object or by the drawing context (I'm still not quite comfortable with 
 all the graphics theory; indeed, this is my first attempt at trying to unlock 
 its mysteries).

You may already know this but the CFAffineTransformMake*() functions apply a 
single operation (rotate, scale or translate) to the identity transform. If, 
for example, you called CGAffineTransformMakeRotation() and then later 
CGAffineTransformMakeTranslation(), then the rotation will be lost.

 What else do I need to do to ensure the new rotated, orientation sticks so 
 that I can move the shape without it reverting to the original orientation?

Keep track of translation and rotation values in your model and then build 
translated+rotated transforms that reflect the current state of each object.

- (IBAction)rotateShape:(UIRotationGestureRecognizer *)gesture {
   modelObject = ...;

   modelObject.rotation = gesture.rotation;
   gesture.view.transform = [self transformForModelObject:modelObject];
}
___

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: NSReleasePool issue

2014-06-20 Thread Steve Christensen
My main() looks like this. Does yours specify an autorelease pool?

int main(int argc, char* argv[])
{
@autoreleasepool
{
return UIApplicationMain(argc, argv, nil, 
@MyDelegateClassName);
}
}


On Jun 19, 2014, at 5:45 PM, Varun Chandramohan varun.chandramo...@wontok.com 
wrote:

 I was playing around with OBJ_DEBUG_MISSING_POOL env variable and set it to 
 YES. I was able to debug most of the issues in my code where I missed auto 
 release pools. This is the last one remaining. However I am not sure where 
 the leak is happening. It looks like NSApplicationMain, do that also need 
 this auto release pool?
 
 objc[26109]: MISSING POOLS: Object 0x618410e0 of class NSUserDefaults 
 autoreleased with no pool in place - just leaking - break on 
 objc_autoreleaseNoPool() to debug
 
 (lldb) bt
 
 * thread #1: tid = 0x3d3c5f, 0x7fff91da8604 
 libobjc.A.dylib`objc_autoreleaseNoPool, queue = 'com.apple.main-thread', stop 
 reason = breakpoint 1.1
frame #0: 0x7fff91da8604 libobjc.A.dylib`objc_autoreleaseNoPool
frame #1: 0x7fff91d95488 libobjc.A.dylib`(anonymous 
 namespace)::AutoreleasePoolPage::autoreleaseSlow(objc_object*) + 72
frame #2: 0x7fff91da8781 
 libobjc.A.dylib`_objc_rootAutorelease2(objc_object*) + 75
frame #3: 0x7fff895528a3 AppKit`_NSGetBoolAppConfig + 85
frame #4: 0x7fff89571566 AppKit`-[NSApplication 
 _installMemoryPressureDispatchSources] + 161
frame #5: 0x7fff89565861 AppKit`-[NSApplication run] + 206
frame #6: 0x7fff895507a3 AppKit`NSApplicationMain + 940
  * frame #7: 0x00012022 TOS`main(argc=3, argv=0x7fff5fbffa90) + 
 34 at main.m:13

___

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: Contribute some dictionary keys with registerDefaults

2014-06-18 Thread Steve Christensen
When you call -setObject:forKey:, it replaces the entire contents of that key, 
whether the object is a number, string, dictionary, etc. That’s the same 
behavior as if you called -setObject:forKey: on a regular dictionary when one 
of its objects is, itself, a dictionary.

Depending on what you need to be doing, you could go a couple of routes:

1. Add a category on NSUserDefaults to handle getting/setting those values that 
are organized in a sub-dictionary.

2. Create a custom class that manages all of your settings and don’t call 
NSUserDefaults directly outside of that class.

I’ve tended to go with the latter method myself. It allows me to type the 
property value, i.e., int or long instead of NSNumber*, or NSString* instead of 
id; it allows me to range-check and otherwise validate values before storing 
them; and it means that NSUserDefaults property keys are only managed in one 
place so I don’t have to worry about key typos in other files that would have 
me accessing the wrong value or an unknown value.


On Jun 18, 2014, at 5:22 AM, Jonathan Taylor jonathan.tay...@glasgow.ac.uk 
wrote:

 I currently have a plist which contains some configuration values; at start 
 of day I use the following call to make certain factory settings available 
 to the application through NSUserDefaults:
   [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary 
 dictionaryWithContentsOfFile:configPath]];
 
 This works fine with single-object keys. i.e. I can include a key of type 
 Number in the plist file, and it will be made available in the same way as 
 other user defaults.
 
 However some of my user defaults are organised within a dictionary (e.g. 
 there is a dictionary for each separate camera connected to the system, 
 tracking user-controllable defaults such as chosen framerate). I would like a 
 way to contribute factory settings from my plist for some of those key 
 values. However if I include a dictionary in my plist, and separately call 
   [[NSUserDefaults standardUserDefaults] setObject:aDictionary 
 forDefault:@my_camera_key];
 then this dictionary object fully overrides the entire dictionary object that 
 I supplied for my_camera_key in the plist. I had thought there was an outside 
 chance that it would effectively merge the two dictionaries together, looking 
 for a specific key first in the dictionary object in the user-specified 
 defaults and then falling back to the dictionary object I supplied through 
 registerDefaults. This does not appear to be the case though.
 
 Not sure if this makes sense - perhaps an example will help.
 
 plist supplied to registerDefaults contains:
 my_camera_key dictionary
 my_camera_key.key1 = 4
 my_camera_key.key2 = 5
 
 dictionary passed to setObject:forDefault:@my_camera_key contains:
 key1=7
 key3=1
 
 I had vaguely hoped that if I then called 
 [[NSUserDefaults standardUserDefaults] objectForKey:@my_camera_key]
 then I might get back a dictionary containing three objects:
 key1=7
 key2=5
 key3=1
 
 
 Can anyone suggest how I might achieve what I am trying to do here? (Or 
 suggest a better mechanism of doing what I want to do, i.e. maintain some 
 sort of hierarchy to my defaults, but also be able to supply factory settings 
 for objects below the top level of the hierarchy?
 
 Thanks for any suggestions
 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: JSONSerialization 'Garbage at end' error

2014-04-30 Thread Steve Christensen
I’m already doing downloads in my app using NSURLSession so I used my existing 
code to download and decode the data returned by the URL below and didn’t get 
an error. I am building against iOS 7.1 and I tried it out in the simulator.

Doing a brief search, it seems like when others are running into this error, 
they’re working with JSON data that really does have garbage at the end. Is it 
possible that you’re doing something like appending a null terminator or 
something else non-printable so that when you look at the data then it all 
seems OK?


On Apr 30, 2014, at 8:20 AM, Diederik Meijer | Ten Horses 
diede...@tenhorses.com wrote:

 Hi all,
 
 I have Googled this issue for hours and tried various solutions suggested at 
 Stackoverflow, but can't seem to solve the following problem.
 
 I am pulling JSON from here: 
 http://www.tenhorses.com/apps/meijburg/dotTAXDataHandler/dotTAXtaxNotesAPI.php
 
 Both JSONLint, http://jsonformatter.curiousconcept.com and freeformatter.com 
 say this is valid JSON.
 
 I am using the NSURLConnection delegate methods (appending data as it comes 
 in to a NSMutableData object) and are  serialising the downloaded data in the 
 didFinishLoading like so:
 
NSError *error;
id jsonObject = [NSJSONSerialization JSONObjectWithData:self.container 
 options:NSJSONReadingAllowFragments error:error];
if (error) {
NSLog(@ERROR: %@, error);
}
else {
if ([self.type isEqual:@people] || [self.type isEqual:@projects] 
 || [self.type isEqual:@taxNotes]) jsonObject = [jsonObject 
 objectForKey:@items];
NSString *notificationName = [NSString 
 stringWithFormat:@%@DataDownloaded, self.type];
[[NSNotificationCenter defaultCenter] 
 postNotificationName:notificationName object:nil userInfo:[NSDictionary 
 dictionaryWithObject:jsonObject forKey:@jsonArray]];
[sharedConnectionList removeObject:self];
}
 
 
 In short this sends off a notification with a pointer to an NSArray in case 
 the downloader object's type is 'people', projects' or 'taxNotes' and to a 
 NSDictionary in other cases.
 
 Now here is the problem: although the JSON parses fine and populates a 
 UITableView without any issues, I am still getting the following error:
 
 Error Domain=NSCocoaErrorDomain Code=3840 The operation couldn’t be 
 completed. (Cocoa error 3840.) (Garbage at end.) UserInfo=0xa2329a0 
 {NSDebugDescription=Garbage at end.}
 
 I tested by creating an NSString from the data object and adding a few 
 characters at the end. Never does that reveal anything that should be there 
 at the end of the JSON string.
 
 This, in itself, is slightly unsettling, but not critically wrong..
 
 Has anybody here experienced a similar issue?
 
 If so, can you tell me how to fix this?
 
 Many thanks,
 
 Diederik


___

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: Navigation Design question

2014-04-13 Thread Steve Christensen
Why not just make a common UIViewController subclass that manages the global 
menu button, and then subclass that class for each of the controllers that live 
on your navigation stack? If it contains the ivar for the UINavigationItem 
(marked @protected) instead of having that ivar in each of the custom 
controllers, then it has access to it to manage the global menu button, and the 
subclasses can also perform whatever custom bits are required. It also means 
that each of the sub-subclasses don’t need to be calling -addBarButtonItem:… or 
know how the global menu works. The controller class that knows about the 
global menu button then implements -addMenuOption: (not 
-addMenuOption:navigationItem:, since it already knows the navigation item) and 
the sub-subclasses call it to add an option.


On Apr 13, 2014, at 2:55 PM, Luther Baker lutherba...@gmail.com wrote:

 Hello all,
 
 I've run into an issue a few times and I'd like to see if someone has a
 good design suggestion to address my problem.
 
 Consider an iPad or iPhone application based on a UINavigationController -
 that displays a 'menu' button in the UINavigationBar. The navbar renders
 UIBarButtonItems ... which we set per the UIViewController level via the
 UINavigationItem which is available to us via the UIViewController.
 
 Now, I've got to render, for lack of a better term, a _global_ menu. I need
 the exact same button to simply stick to the upper left or right hand side
 of the nav bar. Consider that the button triggers the display of a
 UIPopoverController with a tableview which again, has _global_ style
 options. Specifically, and to keep the example simple, this menu has
 nothing to do with the child view controller. Maybe menu options include
 LOGOUT, or display SETTINGS or maybe there is an option to modally presents
 a report.
 
 How can I get this to show up - without forcing every single view
 controller to _know_ about this global menu, jam it into their own
 self.navigationItem.leftBarButtonItem property and be sure to register a
 handler from somewhere to do the right thing.
 
 What I think I _really_ want is a design wherein the view controller
 essentially _asks_ the navigation controller to either (a) add a very
 specific UIBarButtonItem to the navigation bar (which would allow the
 navigation controller to add the button to an array if a global button
 already existed) ... or (b) add a selection option - which the navigation
 bar could decide how to handle (create a new button, or insert into an
 existing menu, etc).
 
 What makes rolling my own wrappers around this difficult is that those
 things are set via the UINavigationItem - which is very very specific to
 the view controller itself - it isn't directly available to the navigation
 controller per se.
 
 I'm leaning towards adding something like:
 
- (void)addBarButtonItem:(UIBarButtonItem *)barButtonItem
 toNavigationItem:(UINavigationItem *)navigationItem;
 
- (void)addMenuOption:(idMenuOption)option
 toNavigationItem:(UINavigationItem *)navigationItem;
 
 to either a category or subclass of the UINavigationController I am using
 to handle the case where I want to _add_ my requirements to whatever the
 UINavigationController is already displaying ... the problem is, if a view
 controller has _nothing_ to add to the nav bar, the global menu addition
 wouldn't get triggered 
 
 I wonder if I need to shift my focus to the UINavigationBar itself -- and
 intercept calls trying to create buttons ... but that be new territory for
 me as I've always just depended on the meta-informational style of using
 the view controller's UINavigationItem.
 
 Any thoughts on this? Has anyone discovered a better way to do this without
 cluttering up every child view controller's SRP with the necessity to set
 buttons for someone else while retaining ultimate flexibility to set their
 own -- while still not having a way to 'insert' an option into an existing
 partially _global_ menu that is floating from vc to vc.
 
 I essentially don't want view controllers setting these items directly - I
 want them to _add_ items - not _set_ them. And I'm not sure how to do this
 within the design paradigm of the view controller's navigation item
 instance - since that just puts me at one more level of direction (someone
 else reads that object and then builds out the UINavigationBar accordingly).
 
 Ok - getting wordy and repetitive. Hope I've said enough to be clear what
 I'm trying to do.
 
 Thanks,
 -Luther
 ___
 
 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/punster%40mac.com
 
 This email sent to puns...@mac.com


___

Cocoa-dev mailing list 

iOS: Cannot connect to iTunes Store

2014-04-10 Thread Steve Christensen
I’ve been testing IAP in the sandbox store on a development iPod and just 
started getting this error in -paymentQueue:updatedTransactions: with 
(transaction.transactionState == SKPaymentTransactionStateFailed):

Error Domain=SKErrorDomain Code=0 Cannot connect to iTunes Store 
UserInfo=0x1aa5e060 {NSLocalizedDescription=Cannot connect to iTunes Store}

Note that this had been working just fine until a couple of days ago. The only 
change that I can think of is that I did an upgrade from 7.0.6 to 7.1, but I 
don’t remember if it was before or after the last time I tried this and it 
worked.

In doing some reading, one poster pointed out that one of the reasons for this 
could be that I messed up the test user account so I signed out of the old test 
user in the Settings app, created a new test user in iTunes Connect, then went 
through another purchase cycle. It asked me to log in (which I did with the new 
user) and then presented the purchase confirmation alert with the product name 
and price, and [Environment:Sandbox]. I tapped on the Buy button and then got 
the error above.

Does anyone have an idea of what else I should be checking?

Thanks.
___

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: Custom UITableViewCell parent is NIL

2014-04-08 Thread Steve Christensen
On Apr 7, 2014, at 9:32 PM, Michael de Haan m...@comcast.net wrote:

 It still however leaves me puzzled as to why I cannot implement Swipe to 
 delete. (the 2 usual suspects), ie 
 
 -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath 
 *)indexPath;
 -(void)tableView:(UITableView *)tableView 
 commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
 forRowAtIndexPath:(NSIndexPath *)indexPath
 
 are implemented.

I realize that this will come across as a “is it plugged in?” sort of question, 
but have you put a breakpoint, or added a NSLog(), to each of those methods to 
see if they’re actually being called? And if -tableView:canEditRowAtIndexPath: 
is being called, are there any cases where you return NO?


___

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: UILabel HTML to attributed string conversion: odd font choice for em text

2013-12-17 Thread Steve Christensen
On Dec 17, 2013, at 1:04 PM, Jens Alfke j...@mooseyard.com wrote:

 On Dec 17, 2013, at 10:44 AM, Steve Christensen puns...@mac.com wrote:
 
 This seems odd to me since there's a perfectly fine Avenir Next Medium 
 Italic available. Is this an expected font choice for italic text given the 
 setup above
 
 That seems wrong to me too.
 
 I just experimented in TextEdit on OS X 10.9 — created some text in Avenir 
 Next Medium, then italicized one word. It came out Avenir Next Italic (not 
 Medium Italic), which is slightly wrong (too light) but not as wrong as what 
 you got on iOS.
 
 My best guess is that the metadata in the fonts themselves is wrong: maybe 
 Medium Italic doesn’t have the same weight value as Medium.

I just specifically set up an em run to use Avenir Next Medium Italic and I 
can't see any difference in font weight, so if it's something like that then 
the algorithm that makes that determination is pickier about it than I.

 and, more importantly, is there a way for me to end up with an attributed 
 string that's using the italic version of the base font short of manually 
 walking each of the attribute runs and correcting the font?
 
 You could try creating some CSS to define a custom font/style mapping, then 
 insert that into the HTML…

I'm doing this same sort of thing in several locations within the app which 
would mean providing CSS for each as a workaround. Not the most elegant 
solution but for now I have ended up post-processing the attributed string, 
replacing the font in italicized runs with an italicized version of the base 
font. If someone else can provide further enlightenment into something I've 
done wrong and how to fix it then I can rip out this bit but for now this will 
do.

Thanks, Jens.

- Steve
___

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

UILabel HTML to attributed string conversion: odd font choice for em text

2013-12-17 Thread Steve Christensen
I have formatted text delivered to the app as HTML that I am converting to a 
NSAttributedString and then assigning to a UILabel like this:

NSDictionary* options =
@{
NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding),
NSDefaultAttributesDocumentAttribute:
@{
NSFontAttributeName:label.font,
NSForegroundColorAttributeName: label.textColor,
NSStrikethroughStyleAttributeName:  @1,
NSUnderlineStyleAttributeName:  
@(NSUnderlineStyleSingle)
},
NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType
};

attributedString = [[NSAttributedString alloc] initWithData:data 
options:options documentAttributes:NULL error:error];

label.attributedText = attributedString;


The UILabel has its font set to Avenir Next Medium, which the code above uses 
as the base font for the attributed string. The HTML is of the form:

pBlah blah blah emblah blah blah/em blah blah blah/p

What I'm seeing visually is that the normal paragraph text is fine but that the 
text inside the em tag is nearly unreadable. I added code to dump out the 
attribute runs and found that the starting paragraph text is what's expected:

NSFont = UICTFont: 0x14c51680 font-family: \AvenirNext-Medium\; 
font-weight: normal; font-style: normal; font-size: 16.00pt;

but that the text inside the em tag uses Avenir Next UltraLight Italic:

NSFont = UICTFont: 0x14c51ee0 font-family: \AvenirNext-UltraLightItalic\; 
font-weight: normal; font-style: italic; font-size: 16.00pt;

This seems odd to me since there's a perfectly fine Avenir Next Medium Italic 
available. Is this an expected font choice for italic text given the setup 
above and, more importantly, is there a way for me to end up with an attributed 
string that's using the italic version of the base font short of manually 
walking each of the attribute runs and correcting the font?

Thanks,
Steve


___

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)

2013-11-25 Thread Steve Christensen
I haven't seen anything that directly returns this information. Given that, it 
might be better to take the approach of choosing the number of cards that look 
good on an iPad mini and not worrying so much that there are too few on a 
full-sized iPad.


On Nov 25, 2013, at 4:40 AM, Roland King r...@rols.org wrote:

 Is there yet a supported way of finding out the actual screen size (or 
 equivalently pixel density) on an iOS screen? 
 
 I have an app, uses autolayout, works fine on iPhone (one storyboard), iPad 
 (another storyboard) and mostly looks fine between iPad and iPad mini. One 
 screen however has a number of test 'cards' on it. On the phone one card == 
 one screen looks great. On a full-sized iPad, about 6 to a page is clear, on 
 a mini however 6 is not ideal and 4, or 3, looks much better and is much 
 clearer to test. That's one of the fairly rare cases where one size doesn't 
 fit all and knowing the actual screen dimensions would make a better user 
 experience. 
 
 I know there was lots of chat about this when the mini came out, there wasn't 
 anything then and I don't want to do one of the version or device name hacks. 
 Is there yet an API point 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Infinite Scroll View?

2013-10-08 Thread Steve Christensen
Does (scrollView.contentOffset.x = 0) not work? How are you testing for it now?


On Oct 8, 2013, at 12:20 PM, Dave d...@looktowindward.com wrote:

 Hi,
 
 I finally managed to get back on this! I've got it working when scrolling 
 from left to right and can detect when the user scrolls past the last item, 
 however, I can't seem to find a way to detect when the user scrolls to before 
 the first item. 
 
 I get -0 for offset X
 
 2013-10-08 20:18:20.607 LTWScrollTest1[17988:a0b] contentOffset: {-0, 0}
 
 But that doesn't do me much good!
 
 It seems to work quite nicely going left to right, but having difficulties 
 figuring out how to make it work scrolling right to left.
 
 
 Any idea greatly appreciated as I'm need to get this working for tomorrow 
 morning!
 
 Thanks a lot.
 
 All the Best
 Dave
 
 
 
 On 8 Oct 2013, at 08:56, Kyle Sluder k...@ksluder.com wrote:
 
 On Oct 8, 2013, at 12:44 AM, Dave d...@looktowindward.com wrote:
 
 Thanks Kyle,
 
 That's what I was trying to figure out, whether I needed to re-layout the 
 views based on the positions or whether I could just do it by keeping an 
 Array of the image views separately and rotating this as it scroll past the 
 end. I sort of got this working, but of course the Subviews of the Scroll 
 View just grows and grows! 
 
 This is what I got at the moment:
 
 //  Scroll past last item detected (in the scrollViewDidScroll delegate 
 method)
 
  if (theScrollView.contentSize.width - theScrollView.contentOffset.x = 
 1024)
  {
  myContentInfo = [self.pContentArray objectAtIndex:0];
  [self.pContentArray addObject:myContentInfo];
  [self.pContentArray removeObjectAtIndex:0];
 
  [self addContentInfo:myContentInfo withEndFlag:YES];
  }
 
 Which kind of works, but obviously isn't the way to do it. 
 
 Thanks for confirming I needed to use -layoutSubviews, I'm about to start 
 on this track now.
 
 You don’t *have* to use -layoutSubviews, but you'll probably get the best 
 results if you do. You could theoretically do this all in the delegate's 
 implementation of -scrollViewDidScroll:, but that’ll probably double the 
 number of layout passes and certainly multiply the number of message sends. 
 When scrolling, you want to avoid as much unnecessary work as is reasonable.
 
 It’s kind of a bummer that you’re going to need to split your logic up 
 between the scroll view and its delegate, thus tightly coupling the two. I 
 wish the frameworks exposed many more of their delegate hooks as subclass 
 hooks as well. Scroll views seem to stir this desire particularly frequently.
 
 --Kyle Sluder
 
 
 ___
 
 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/punster%40mac.com
 
 This email sent to puns...@mac.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: Infinite Scroll View?

2013-10-07 Thread Steve Christensen
Have you thought about representing your images as cells in a UITableView? If 
so, you could use something like BBTableView 
(https://github.com/bharath2020/UITableViewTricks). It's a subclass of 
UITableView lays out cells along an arc but it also has support for infinite 
scrolling, so you could just use the relevant pieces. Plus UITableView will 
handle putting the right image in the right vertical location, based on your 
data source.


On Oct 7, 2013, at 9:21 AM, Dave d...@looktowindward.com wrote:

 Hi,
 
 I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the scrolling 
 is past the last item in the Scroll start displaying the first and when 
 scrolling before the first item, starting displaying the last. The items in 
 this case are UIImageViews and they have a fixed height and a variable width 
 and no one image will be wider that the Scroll View itself. Also it needs to 
 work with pagingEnables = NO, e.g. there will be more than one Image visible.
 
 I've playing around a bit and found a some sample code that sort of does it 
 but it doesn't handle the wrapping the Images smoothly (is was written to 
 have paging enabled). 
 
 My plan was/is to detect when the scrolling had hit before the first/after 
 the last and to move the first Subview to the End or the Last one to the 
 beginning, depending on the direction of movement, but at the moment, I can't 
 seem to see a way of detecting these conditions.
 
 I logged contentOffset and contentSize in the scrollViewDidScroll delegate 
 method and got these results:
 
 
 scrollViewDidScroll Offset: {4017, 0}   - Size: {5119, 200}
 scrollViewDidScroll Offset: {4061, 0}   - Size: {5119, 200}
 scrollViewDidScroll Offset: {4095, 0}   - Size: {5119, 200}
 
 When hitting the end and
 
 scrollViewDidScroll Top Scroll View Offset: {106, 0}  - Size: {5119, 200}
 scrollViewDidScroll Top Scroll View Offset: {24, 0}   - Size: {5119, 200}
 scrollViewDidScroll Top Scroll View Offset: {-0, 0}   - Size: {5119, 200}
 
 When hitting the start.
 
 I'm not sure how if I can detect the start/end conditions using these values?
 
 Any points on the best way to implement this would greatly appreciated!
 
 All the Best
 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: Infinite Scroll View?

2013-10-07 Thread Steve Christensen
Does it not work to set the row height to the height of each of the images and 
then use a custom UITableViewCell that contains a UIImageView that fills the 
cell? The other benefit is that you don't have to have more images in memory 
than are visible within the table view's frame. (This may not be an issue if 
there aren't that many, of course.)


On Oct 7, 2013, at 10:25 AM, Dave d...@looktowindward.com wrote:

 Hi,
 
 I don't think that will work for me in this case as I need the images to be 
 scrolled smoothly without gaps and AFAIK, using a table view cell will cause 
 a gap - you can add a fragment of an image.
 
 Thanks anyway
 All the Best
 Dave
 
 On 7 Oct 2013, at 18:11, Steve Christensen puns...@mac.com wrote:
 
 Have you thought about representing your images as cells in a UITableView? 
 If so, you could use something like BBTableView 
 (https://github.com/bharath2020/UITableViewTricks). It's a subclass of 
 UITableView lays out cells along an arc but it also has support for infinite 
 scrolling, so you could just use the relevant pieces. Plus UITableView will 
 handle putting the right image in the right vertical location, based on your 
 data source.
 
 
 On Oct 7, 2013, at 9:21 AM, Dave d...@looktowindward.com wrote:
 
 Hi,
 
 I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the 
 scrolling is past the last item in the Scroll start displaying the first 
 and when scrolling before the first item, starting displaying the last. The 
 items in this case are UIImageViews and they have a fixed height and a 
 variable width and no one image will be wider that the Scroll View itself. 
 Also it needs to work with pagingEnables = NO, e.g. there will be more than 
 one Image visible.
 
 I've playing around a bit and found a some sample code that sort of does it 
 but it doesn't handle the wrapping the Images smoothly (is was written to 
 have paging enabled). 
 
 My plan was/is to detect when the scrolling had hit before the first/after 
 the last and to move the first Subview to the End or the Last one to the 
 beginning, depending on the direction of movement, but at the moment, I 
 can't seem to see a way of detecting these conditions.
 
 I logged contentOffset and contentSize in the scrollViewDidScroll delegate 
 method and got these results:
 
 
 scrollViewDidScroll Offset: {4017, 0}   - Size: {5119, 200}
 scrollViewDidScroll Offset: {4061, 0}   - Size: {5119, 200}
 scrollViewDidScroll Offset: {4095, 0}   - Size: {5119, 200}
 
 When hitting the end and
 
 scrollViewDidScroll Top Scroll View Offset: {106, 0}  - Size: {5119, 200}
 scrollViewDidScroll Top Scroll View Offset: {24, 0}   - Size: {5119, 200}
 scrollViewDidScroll Top Scroll View Offset: {-0, 0}   - Size: {5119, 200}
 
 When hitting the start.
 
 I'm not sure how if I can detect the start/end conditions using these 
 values?
 
 Any points on the best way to implement this would greatly appreciated!
 
 All the Best
 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: How to get variably sized header in a UICollectionView supporting both orientations

2013-10-04 Thread Steve Christensen
On Oct 4, 2013, at 1:52 PM, David Hoerl dho...@mac.com wrote:

 But its really odd - and I'm thinking about a bug report on this - that the 
 delegate has to provide the size before the view is even created.

It make sense if you think about it: it's asking for sizes so that scroll view 
contentSize can be set and the layout can be determined. It would be a lot more 
expensive to have to actually build each of the cells for the entire collection 
just to get their sizes. This sort of behavior also happens with UITableView 
and its various cells.


___

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: Efficient UITableViewCell usage

2013-09-30 Thread Steve Christensen
The table view needs to call -heightForRowAtIndexPath: for each cell in the 
table, at the very least, so that it knows how tall the table is so that it can 
set -contentSize on it's underlying scroll view.

For performance, you could calculate and cache the cell heights in an array 
managed by your view controller, then just return the cached values. If you 
calculate them in your view controller's -viewWillLayoutSubviews method then 
you can adjust the heights when the screen rotation changes.

Sent from my iPhone

 On Sep 30, 2013, at 7:47 AM, Koen van der Drift koenvanderdr...@gmail.com 
 wrote:
 
 Hi,
 
 I have a custom UITableViewCell with several labels of which the size needs 
 to be calculated based on the content.  Some of the content is also 
 constructed on the fly, since I am generating an attributed string, and don't 
 want to store these in my model objects.
 
 The frame is calculated in heightForRowAtIndexPath: and layoutSubviews of my 
 custom cell.  The attributed string is calculated in heightForRowAtIndexPath: 
 and cellForRowAtIndexPath:
 
 I put in some logs to see the order in which these methods are called, see 
 below.  Surprisingly (at least for me), heightForRowAtIndexPath is called for 
 every row first, even the ones that are not yet visible. So when my data 
 array is really large, this could take up some time, and I can see that when 
 the table is drawn.
 
 There must be a more clever way to do this?
 
 - Koen.
 
 
 
 2013-09-30 09:50:30.674 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.675 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.676 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.677 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.677 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.678 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.679 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.680 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.680 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.681 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.682 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.683 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.683 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.684 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.685 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.686 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.686 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.687 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.688 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.688 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.689 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.690 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.691 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.691 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.692 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.693 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.693 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.694 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.695 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.696 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.697 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.697 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.698 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.699 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.700 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.701 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.701 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.702 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.703 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.704 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.704 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.705 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.706 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.707 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.707 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.708 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.709 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.709 MyApp[23200:a0b] heightForRowAtIndexPath
 2013-09-30 09:50:30.727 MyApp[23200:a0b] cellForRowAtIndexPath
 2013-09-30 09:50:30.729 MyApp[23200:a0b] cellForRowAtIndexPath
 2013-09-30 09:50:30.731 MyApp[23200:a0b] cellForRowAtIndexPath
 2013-09-30 09:50:30.732 MyApp[23200:a0b] cellForRowAtIndexPath
 2013-09-30 09:50:30.734 MyApp[23200:a0b] cellForRowAtIndexPath
 2013-09-30 09:50:30.735 

Re: Optimal height for WebView

2013-01-04 Thread Steve Christensen
On Jan 4, 2013, at 10:40 AM, Mike Abdullah wrote:

 On 4 Jan 2013, at 18:12, Eric Gorr mail...@ericgorr.net wrote:
 
 Good point Mike.
 
 However, after it has completed the layout, is it possible to determine the 
 height of the content? If so, i could probably work with that information.
 
 But, I would still think it was possible to provide a method with a fixed 
 width, have it perform a layout, and return the height - that is essentially 
 what the stackoverflow solution does, just in a rather convoluted way.
 
 Well you've got the whole DOM API to play with. I'd have a play around with 
 computed style etc. to see if you can pull out a useful figure.


Ask the DOM what the height is. I use jquery but you could just as easily use 
standard Javascript methods to get the height.

- (void) webViewDidFinishLoad:(UIWebView*)webView
{
height = [[webView 
stringByEvaluatingJavaScriptFromString:@$(document).height();] integerValue];
}

___

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: stripped down webview

2012-08-18 Thread Steve Christensen
How about asynchronously downloading the page HTML into a string, doing a text 
replace of the name of the CSS file to your local one, then passing the 
modified HTML to the web view?

Sent from my iPhone

On Aug 18, 2012, at 6:52 AM, Koen van der Drift koenvanderdr...@gmail.com 
wrote:

 
 On Aug 18, 2012, at 7:24 AM, Koen van der Drift koenvanderdr...@gmail.com 
 wrote:
 
 In my OS X app I show some webpages in a WebView, but I'd like to show them 
 stripped down, remove clutter, e.g. as is done in Evernote and other apps. 
 
 Any suggestions where to start? Maybe use a local css file?
 
 
 
 Answering to myself...
 
 
 Alright, I found some clues on SO, and am now able to replace the css file 
 with my own by tweaking the DOMDocument.  The only place I could think of to 
 do this is in
 
 - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
 
 But since the webview loads asynchronously,  I first see the page with the 
 original css for a second or two, and then it changes to the page using my 
 local css file only after the whole page has loaded.
 
 Is there another place where I could hook into so the page shows correctly 
 immediately?  
 
 
 Next is to strip the DOM form all elements I don't need :)
 
 - Koen.
 
 
 
 
 
 ___
 
 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/punster%40mac.com
 
 This email sent to puns...@mac.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: What causes a UITableViewCell to be deallocated?

2012-01-23 Thread Steve Christensen
A UITableViewCell could be deallocated as soon as its row scrolls out of view. 
UITableView will reuse cells if you specify a reuse identifier, but I don't 
believe that the docs actually specify the number of cells that are reused.

I'm assuming that the web view is displayed when the user taps a link in the 
UITextView. If so, when does the crash occur relative to the appearance of the 
web view?


On Jan 23, 2012, at 11:38 AM, Laurent Daudelin wrote:

 I'm trying to track a crash in our app where we have a custom UITableView 
 cell that contains a UITextView because we need the ability to display and 
 open links that might be in the text we're displaying in the text view.
 
 The problem is that somehow, the cell is deallocated and WebKit complains 
 that it's been unable to obtain the web lock from a thread other than the 
 main thread or the web thread when it's deallocated. I have reviewed the code 
 and checked all the reload… message we might send to the table view that 
 could cause the deallocation of its cells but all of those calls are executed 
 from the main thread using [[NSOperationQueue mainQueue] 
 addOperationWithBlock:^{…}] so I'm stumped. Are there any other situations 
 where UITableView cells would be deallocated? The view displays and the view 
 isn't unloaded due to memory warning or any other situation.


___

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: Is slowing down bindings updates possible?

2012-01-13 Thread Steve Christensen
Why don't you just decouple your UI from the by-the-millisecond download 
process? For example, you could update calculated values whenever the value of 
bytesDownloaded changes but use a NSTimer to update the display of those values 
maybe once or twice a second. The display is then sampling the download process 
periodically rather than recording every single change, which should also 
reduce the amount of time spent redrawing the display.


On Jan 12, 2012, at 9:57 PM, Andrew wrote:

 I have a download controller with an NSMutableArray and an
 NSArrayController hooked up to a NSTableView with a view based setup.
 My array contains custom download objects. Each of those has a
 NSURLDownload instance.
 
 Basically, I am showing a browser-download like interface with size
 downloaded, total expected size, a progress bar, time elapsed,
 download rate and estimated time left.
 
 It is all working wonderfully, but actually too well. Right now, I am
 using will/didChangeValueForKey messages to notify observers when the
 number of bytes downloaded changes. I am doing this in the callback
 method:
 
 - (void)download:(NSURLDownload *)download
 didReceiveDataOfLength:(NSUInteger)length
 {
  [self willChangeValueForKey:@bytesDownloaded];
  _bytesDownloaded += length;
  [self didChangeValueForKey:@bytesDownloaded];
 }
 
 The result of this is that the UI updates really frequently and the
 estimated time to complete and the download rate jump around a lot. I
 would love it if I could tell cocoa to only update the UI once per
 second instead of immediately when the property key changes.
 
 With a bit of work I could probably set up a proxy object for each
 download that would do something like that and use timer, but it would
 be a lot of messy code. I could also just delay updating the
 _bytesDownloaded on a queue. Or a third idea is to cache the estimated
 calc time and rate and then only recalculate the value at most once
 per second.
 
 Any other brighter ideas? Thoughts?

___

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: UIWebView and Mobile Safari event handling problem (iOS)

2012-01-08 Thread Steve Christensen
It looks like UIWebView snarfs up all the gestures by default. I had a project 
where I needed to see a tap on the web view without otherwise disrupting the 
normal behavior. I ended up creating a UITapGestureRecognizer, set its delegate 
to self, and then implemented 
-gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:, always 
returning YES. Perhaps something similar would work for you.


On Jan 4, 2012, at 7:05 AM, Nick wrote:

 Hi!
 I have a web page that handles finger dragging (it's a simple
 presentation auto generated from a PPS presentation, with pages
 animatedly flipped when the mouse is dragged - with the help of
 JavaScript). On Mobile Safari it works just fine, but on UIWebView,
 the pages are not being flipped.The nice page flipping animation
 doesn't work on UIWebView, and it behaves strangely in general. I
 guess I should pass somehow these dragging events to the view, so it
 behaves like Safari? How could I fix this?
 
 This UIWebView also handles double taps (by zooming in the view - but
 again, with no animation, unlike Mobile Safari), and zoomed area can't
 be scrolled on UIWebView (unlike Safari). Apparently because because
 the operation requires this dragging event, which is not passed to the
 web page?
 
 The main question is - why Mobile Safari renders the page correctly
 with all the animation, while UIWebView doesn't? Aren't they the same,
 in the HTML/JS rendering regard?

___

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: Storyboard SplitViewController example

2011-12-25 Thread Steve Christensen
On Dec 24, 2011, at 7:13 PM, Jamie Daniel wrote:

 I am very new to Xcode and iPad development. I am trying to do the following:
 
 I have an initial NavigationController and ViewController. I am trying to go 
 from a button on the ViewController to a SplitViewController using 
 Storyboards but I can't seem to get it to work. Does anyone have an example 
 of how to do it? Or an example of how to hand code it?

The iPad-Specific Controllers section of the View Controller Programming Guide 
for iOS specifically says:

A split view controller must always be the root of any interface you create. 
In other words, you must always install the view from a UISplitViewController 
object as the root view of your application’s window. The panes of your 
split-view interface may then contain navigation controllers, tab bar 
controllers, or any other type of view controller you need to implement your 
interface.

This topic has come up here in the past, so you may want to search the archives.

Also, you cross-posted to the Xcode mailing list. This would be off-topic there 
so I removed it in this reply.

___

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: NSString looses Umlaute

2011-12-22 Thread Steve Christensen
And just to add in one more bit about why it's important to separate the text 
from the binary header, -initWithData:encoding: [r]eturns nil if the 
initialization fails for some reason (for example if data does not represent 
valid data for encoding). (That is from the NSString docs.)


On Dec 22, 2011, at 9:30 AM, Alexander Reichstadt wrote:

 I should add, you are right in that it also says:
 
 n+1, 1 byte, 0x0D stored as the Field Descriptor terminator.
 
 Everything from byte 68 on is then a multiple of 48 bytes, so I can simply 
 check on each 67+(n*48)+1 to see if that byte is 0x0D, which is the marker 
 position of which to follow Mike's advise on getting the subdata.
 
 Alex
 
 
 Am 22.12.2011 um 17:29 schrieb Ken Thomases:
 
 On Dec 22, 2011, at 9:54 AM, Alexander Reichstadt wrote:
 
 The DBF file format documentation says the header is in binary, then there 
 is a linefeed (\r), then there is the body. Each field has a fixed length, 
 wether used or not doesn't matter, the unused rest is filled with spaces.
 
 So, I read the file as data, stringily it as DOSLatin1, split it at the 
 linefeed and read the body according to the field definitions I am given. 
 They are guaranteed, so maybe some day I get around to writing a nice DBF 
 parser, but until then I go by the guaranteed field lengths.
 
 I tested it now on a couple of files and it works without a hitch.
 
 If the header is binary, then any of its bytes might be 0x0D, which is the 
 same as \r (or did you actually mean it when you said linefeed which is 
 0x0A or \n?), so your approach will fail.  In all probability, the header is 
 a fixed length and you can just skip that part of the data.  Either way, if 
 this is meant for more than a casual, one-off, in-house app, you'll have to 
 find a more reliable technique.
 
 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Account validation in CocoaTouch for the purchased app

2011-12-21 Thread Steve Christensen
On Dec 20, 2011, at 2:26 PM, Alexander Reichstadt wrote:

 given an app is sold on iTunes, is there a way for that app to find out which 
 email address was used for the iTunes account when it was purchased?

I don't believe so. As far as I know, the only way to find that out is to ask 
the user.

___

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: Strange NSFileManager file replacement issue

2011-08-19 Thread Steve Christensen
On Aug 19, 2011, at 7:17 AM, Sixten Otto wrote:

 On Thu, Aug 18, 2011 at 10:38 PM, Ken Thomases k...@codeweavers.com wrote:
 
 Those functions, and the general operation that they perform, require that
 the files to be exchanged be on the same file system.
 
 If true, that certainly makes that method far less useful in the general
 case than I expected, and really seems restricted to the saving a new copy
 of an in-memory document and swapping it case. I really don't want to put
 the in-process download into the Documents tree. (Both because it's
 potentially visible to the user through iTunes, and because
 NSTemporaryDirectory() will be swept up occasionally.)

Is there any reason why you can't put the downloaded file in your app's private 
cache directory (.../appdir/Library/Caches), i.e., what gets returned by 
NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)? 
That should certainly be within the bigger app directory hierarchy, and thus a 
peer of the app's Documents directory.


___

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 graphics

2011-07-11 Thread Steve Christensen
The first thing I notice is that none of the CGContext* calls after 
UIGraphicsBeginImageContext is referring to that image context so they are 
having no effect on it. You should move the UIGraphicsGetCurrentContext down 
after the [drawImage...] call.

If you are still not able to get the desired result with any of the Quartz 
blend modes, you'll need to create a bitmap context and tweak the pixels in the 
pixel buffer directly.


On Jul 11, 2011, at 8:48 AM, Development wrote:

 Sorry I figured since it was only a sudo change anyway it wouldn't matter.
 
 UIImage * drawImage = rotatingView.image;
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect newRect = CGRectMake(0.0, 0.0, rotatingView.frame.size.width, 
 rotatingView.frame.size.height);
 
UIGraphicsBeginImageContext(newRect.size);
[drawImage drawInRect:newRect];
CGContextTranslateCTM(context, 0.0, rotatingView.frame.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextClipToMask(context, newRect, drawImage.CGImage);
CGContextSetBlendMode(context, kCGBlendModeHue);
CGContextSetRGBFillColor(context, self.color.r ,self.color.g , 
 self.color.b, 1.0);
CGContextFillRect(context, newRect);
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
 
   This applies a colored rectangle applied over the image and clipped to 
 it as a mask. Which is not what I want. But even it if was the problem is 
 that when I get the png rep so I can save it with transparency to the 
 document, the applied color is lost. An easy way around this is to sable the 
 color values and reapply because when the document is flattened and save as 
 a png the color appears correctly. 
 But again that's effort in the wrong direction anyway.
 A side note the alpha is 1.0 right now, but in the finished product I thought 
 I'd use a slider to adjust that as intensity or something. Anyway it doesn't 
 matter it's just a colored rectangle over top of the image.
 
 
 On Jul 11, 2011, at 5:16 AM, Mike Abdullah wrote:
 
 Giving us a link to the example code would be a big help in understanding 
 what you're trying.
 
 On 11 Jul 2011, at 02:06, Development wrote:
 
 Im having a problem with adjusting the color values of a UIImage.
 
 How does one adjust levels and color values of a UIImage.
 The example code I found only overlays a rectangle clipped to an image 
 mask. It looks like color value adjustment until you realize 2 things.
 a) I absolutely cannot render the image view with the color adjustment into 
 a graphic context with the adjustment in tact, because what I always get 
 back is the original, unadjusted image.
 a b) it's not really adjusting the levels. And since it isn't it also means 
 I cannot actually adjust the brightness, contrast or anything else either.
 
 
 Is adjusting UIImage color levels even possible?

___

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 resolve bulk warning Creating selector for nonexistent method ...?

2011-07-06 Thread Steve Christensen
You mentioned switching between debug and release configurations, so that would 
be a good first place to look since individual build settings can be set on a 
per-configuration basis.


On Jul 5, 2011, at 3:59 PM, arri wrote:

 Hi Steve,
 
 Thanks for your reply! Usually i would be tempted to get to the bottom
 of this and understand where/what mistakes were made (and by who;).
 But other than switching between Debug/Release i hadn't touched the
 build-settings at all, so i figured the problem couldn't be there..
 
 But meanwhile i did managed to 'fix' the issue by clearing Xcode's
 caches ( XCode-app-menu  Empry Caches ).
 Appearanly some things got corrupted and/or confused on that level. As
 a nice bonus, i also got about 10Gb of diskspace back.
 
 So i have no clue what the real problem was, but it's fixed.
 
 thanks,
 arri
 
 
 On Tue, Jul 5, 2011 at 9:17 PM, Steve Christensen puns...@mac.com wrote:
 For the nonexistent method warnings, your project- or target-level settings 
 likely have Undeclared Selector checked in the GCC warnings section of the 
 build settings.
 
 For the multiple selectors warnings, look at the Strict Selector Matching 
 item in the same section. It says this will pop up if you're trying to send 
 the message to a variable of type id, vs to an explicit class type.
 
 
 On Jul 3, 2011, at 6:16 PM, arri wrote:
 
 Hi Motti,
 
 I would be very interested to know how you resolved this issue, if at all.
 
 I'm suddenly facing the same issue, out of no-where. Instead of trying
 to find the source of the problem, I just reverted to the last known
 working version (svn), but the warnings persist.
 This surprises me a bit, because earlier today i had cleaned the
 project and made a release-build for distribution to the client, and
 this went fine.
 
 I'm sure i'm overlooking something very obvious and stupid. Does
 anyone have an idea what that could be?
 
 thanks,
 arri
 
 
 On Mon, Jan 25, 2010 at 12:04 PM, Motti Shneor mot...@waves.com wrote:
 Hi everyone.
 
 I'm building static library, whose outward API is plain C, and whose 
 implementation is Cocoa-based.
 
 It was building and working alright, until (yesterday) something changed, 
 and any attempt to clean/build/rebuild it produces huge amount of 
 compilation warnings, on EVERY Obj-C message.
 
 First, there's a bulk of warnings like this:
 
 /Volumes/Data/.../FileManager_GUI_Mac.mm:224: warning: creating selector 
 for nonexistent method 'openPanel'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:196: warning: creating selector 
 for nonexistent method 'release'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:193: warning: creating selector 
 for nonexistent method 'code'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:190: warning: creating selector 
 for nonexistent method 'savePanel'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:190: warning: creating selector 
 for nonexistent method 'alloc'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:171: warning: creating selector 
 for nonexistent method 'stringWithFormat:'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:160: warning: creating selector 
 for nonexistent method 'getCString:maxLength:encoding:'
 
 Then another bulk of warnings, complaining about DOUBLE definitions for 
 Cocoa methods
 
 /Volumes/Data/.../FileManager_GUI_Mac.mm:244:0
 /Volumes/Data/.../FileManager_GUI_Mac.mm:244: warning: multiple selectors 
 named '+isVertical' found
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSplitView.h:30:0
  
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSplitView.h:30:
  warning: found '-(BOOL)isVertical'
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSliderCell.h:59:0
  
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSliderCell.h:59:
  warning: also found '-(NSInteger)isVertical'
 
 
 
 Notes:
 The project is building Intel-only Universal (32/64bit, architectures i386 
 and x86_64
 I only #import Cocoa/Cocoa.h once, in a single source file (an interface 
 header file).
 I added (linked) the Cocoa Framework once in the project, referencing the 
 Current SDK.
 The project DOES compile, and even works.
 If i turn on the  Build Active Architecture Only build option for the 
 project (ONLY_ACTIVE_ARCH = YES) then I only get the warnings when I 
 compile 32bit. 64bit compilation is free of warnings.
 
 
 These warnings worry me, as I might be using a wrong framework, and the 
 code may break on a user machine.
 
 Any idea will be greatly appreciated.
 
 
 Motti Shneor
 --
 Senior Software Engineer
 Waves Audio ltd.
 
 

___

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

Re: iOS: AVFoundation, AVAssetWriter and caching

2011-07-06 Thread Steve Christensen
With the caveat that I haven't actually tried it, would it make more sense to 
be streaming the movie data to a local file, then specifying the URL/path to 
the file in the initializer method of one of the movie player classes? If the 
player can handle the case where not all the movie data is present then it 
should just do the right thing. The benefit is that you can use the same code 
to play the movie, no matter how much of it is local.


On Jul 5, 2011, at 8:03 PM, John Michael Zorko wrote:

 I'm interested in caching a movie as I play it from the internet, so that the 
 next time the user asks for the movie, it can play it from the device 
 filesystem. I'm thinking capturing frames and audio and using an 
 AVAssetWriter like I would when recording from the camera, but i'm not sure 
 if this will work when recording from a playing asset. Would anyone 
 illuminate me as to whether this is possible, or if I need to explore other 
 ways of doing this (which would probably be a lot less cool and efficient 
 than doing it this way, alas)?

___

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 resolve bulk warning Creating selector for nonexistent method ...?

2011-07-05 Thread Steve Christensen
For the nonexistent method warnings, your project- or target-level settings 
likely have Undeclared Selector checked in the GCC warnings section of the 
build settings.

For the multiple selectors warnings, look at the Strict Selector Matching item 
in the same section. It says this will pop up if you're trying to send the 
message to a variable of type id, vs to an explicit class type.


On Jul 3, 2011, at 6:16 PM, arri wrote:

 Hi Motti,
 
 I would be very interested to know how you resolved this issue, if at all.
 
 I'm suddenly facing the same issue, out of no-where. Instead of trying
 to find the source of the problem, I just reverted to the last known
 working version (svn), but the warnings persist.
 This surprises me a bit, because earlier today i had cleaned the
 project and made a release-build for distribution to the client, and
 this went fine.
 
 I'm sure i'm overlooking something very obvious and stupid. Does
 anyone have an idea what that could be?
 
 thanks,
 arri
 
 
 On Mon, Jan 25, 2010 at 12:04 PM, Motti Shneor mot...@waves.com wrote:
 Hi everyone.
 
 I'm building static library, whose outward API is plain C, and whose 
 implementation is Cocoa-based.
 
 It was building and working alright, until (yesterday) something changed, 
 and any attempt to clean/build/rebuild it produces huge amount of 
 compilation warnings, on EVERY Obj-C message.
 
 First, there's a bulk of warnings like this:
 
 /Volumes/Data/.../FileManager_GUI_Mac.mm:224: warning: creating selector for 
 nonexistent method 'openPanel'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:196: warning: creating selector for 
 nonexistent method 'release'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:193: warning: creating selector for 
 nonexistent method 'code'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:190: warning: creating selector for 
 nonexistent method 'savePanel'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:190: warning: creating selector for 
 nonexistent method 'alloc'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:171: warning: creating selector for 
 nonexistent method 'stringWithFormat:'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:160: warning: creating selector for 
 nonexistent method 'getCString:maxLength:encoding:'
 
 Then another bulk of warnings, complaining about DOUBLE definitions for 
 Cocoa methods
 
 /Volumes/Data/.../FileManager_GUI_Mac.mm:244:0
 /Volumes/Data/.../FileManager_GUI_Mac.mm:244: warning: multiple selectors 
 named '+isVertical' found
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSplitView.h:30:0
  
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSplitView.h:30:
  warning: found '-(BOOL)isVertical'
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSliderCell.h:59:0
  
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSliderCell.h:59:
  warning: also found '-(NSInteger)isVertical'
 
 
 
 Notes:
 The project is building Intel-only Universal (32/64bit, architectures i386 
 and x86_64
 I only #import Cocoa/Cocoa.h once, in a single source file (an interface 
 header file).
 I added (linked) the Cocoa Framework once in the project, referencing the 
 Current SDK.
 The project DOES compile, and even works.
 If i turn on the  Build Active Architecture Only build option for the 
 project (ONLY_ACTIVE_ARCH = YES) then I only get the warnings when I compile 
 32bit. 64bit compilation is free of warnings.
 
 
 These warnings worry me, as I might be using a wrong framework, and the code 
 may break on a user machine.
 
 Any idea will be greatly appreciated.
 
 
 Motti Shneor
 --
 Senior Software Engineer
 Waves Audio ltd.

___

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: Animating handwriting

2011-06-23 Thread Steve Christensen
Is this a correct interpretation of what you're trying to do? You have a title 
string that will be drawn in a handwriting font. You wish to reveal each of the 
letter strokes over time as if someone were actually writing the title on a 
piece of paper.


On Jun 23, 2011, at 9:45 AM, Gustavo Pizano wrote:

 Hello.
 
 Yes kinda.
 
 G.
 On Jun 23, 2011, at 6:34 PM, Conrad Shultz wrote:
 
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 On 6/23/11 6:50 AM, Gustavo Adolfo Pizano wrote:
 Helo Ken.
 
 Thanks for answer,
 I meant, I have some title string already, and I wish to be able to
 animate as if its being written at the moment, also I forgot to
 mention that this is for iOS.
 
 Sorry, do you mean that you have an NSString and a handwriting font,
 and you wish to animate the rendering of the string in that font?
 
 - -- 
 Conrad Shultz
 
 Synthetiq Solutions
 www.synthetiqsolutions.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: iOS: encoding a custom view with a shape in it

2011-06-15 Thread Steve Christensen
On Jun 15, 2011, at 8:29 AM, Development wrote:

 Using the keyed archiver I save all of the values related to the drawing 
 inside of the view. Then of course I save the view's parameters.

OK, I can see archiving the properties of the shape(s) so that you can restore 
them. It sounds like you're trying to archive the view as well, but I'm unsure 
why. A view just provides a place to draw things, but it has nothing to do with 
the data model, so it doesn't really make sense to save it as well. The 
properties needed to draw the shapes should be able to stand independent of the 
view.

 I'm not sure what you mean by the objects it draws?  I'm using CGContext 
 methods to draw rectangles and elipses so other than saving all the values 
 such as transforms and colors and all I'm not sure what you mean.

The objects are the rectangles and ellipses. I had assumed that you created 
shape classes to hold the properties (frame, rotation, color, etc.) and to draw 
those shapes.


 On Jun 11, 2011, at 6:49 PM, Steve Christensen wrote:
 
 And also to clarify, are you freeze drying a view or the objects it draws? 
 You should be doing the latter since that's part of your model.
 
 
 On Jun 11, 2011, at 6:47 PM, Steve Christensen wrote:
 
 How do the results differ between what you saw before and after saving the 
 document? Is everything wrong? or just the scaling, the rotation, what?
 
 And to draw an object, are you using an affine transform just to rotate it 
 or for scaling and/or translation as well?
 
 
 On Jun 9, 2011, at 4:25 PM, Development wrote:
 
 This app allows users to do a number of graphical things. On of those 
 things is to draw rectangles and ellipses.
 
 No it would not be complete if they could not resize and rotate these 
 shapes. Thus the features exist.
 
 The problem comes when I freeze dry the object.
 I encode it exactly as it exists at the moment the saveDocument: option is 
 invoked. 
 colors, frame,rotation etc
 logging these values confirms them
 
 When I unfreeze it, well the values remain identical. hence I know the 
 save worked.
 
 I initialize the object with the decoded rectangle for the frame
 I then apply the transition to rotate it to the correct angle.
 
 hmm the result looks nothing like the initial item did at save time
 
 So I've been looking at this very closely... Is this happening because 
 simply applying the last known frame and angle does not mean it will match?
 If this is the case, does it mean then that in order to preserve the exact 
 state, I must not only save all the data about the object but an array of 
 every change made to the object such as resizes and rotations in order to 
 get the correct result?
 
 My bandaid is to convert the view in to a UIImage and save the image. This 
 fixes the problem however the downside is that special effects that can 
 be applied to rectangles and ellipses are not available on reload.

___

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: encoding a custom view with a shape in it

2011-06-11 Thread Steve Christensen
How do the results differ between what you saw before and after saving the 
document? Is everything wrong? or just the scaling, the rotation, what?

And to draw an object, are you using an affine transform just to rotate it or 
for scaling and/or translation as well?


On Jun 9, 2011, at 4:25 PM, Development wrote:

 This app allows users to do a number of graphical things. On of those things 
 is to draw rectangles and ellipses.
 
 No it would not be complete if they could not resize and rotate these shapes. 
 Thus the features exist.
 
 The problem comes when I freeze dry the object.
 I encode it exactly as it exists at the moment the saveDocument: option is 
 invoked. 
 colors, frame,rotation etc
 logging these values confirms them
 
 When I unfreeze it, well the values remain identical. hence I know the save 
 worked.
 
 I initialize the object with the decoded rectangle for the frame
 I then apply the transition to rotate it to the correct angle.
 
 hmm the result looks nothing like the initial item did at save time
 
 So I've been looking at this very closely... Is this happening because simply 
 applying the last known frame and angle does not mean it will match?
 If this is the case, does it mean then that in order to preserve the exact 
 state, I must not only save all the data about the object but an array of 
 every change made to the object such as resizes and rotations in order to get 
 the correct result?
 
 My bandaid is to convert the view in to a UIImage and save the image. This 
 fixes the problem however the downside is that special effects that can be 
 applied to rectangles and ellipses are not available on reload.

___

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: encoding a custom view with a shape in it

2011-06-11 Thread Steve Christensen
And also to clarify, are you freeze drying a view or the objects it draws? 
You should be doing the latter since that's part of your model.


On Jun 11, 2011, at 6:47 PM, Steve Christensen wrote:

 How do the results differ between what you saw before and after saving the 
 document? Is everything wrong? or just the scaling, the rotation, what?
 
 And to draw an object, are you using an affine transform just to rotate it or 
 for scaling and/or translation as well?
 
 
 On Jun 9, 2011, at 4:25 PM, Development wrote:
 
 This app allows users to do a number of graphical things. On of those things 
 is to draw rectangles and ellipses.
 
 No it would not be complete if they could not resize and rotate these 
 shapes. Thus the features exist.
 
 The problem comes when I freeze dry the object.
 I encode it exactly as it exists at the moment the saveDocument: option is 
 invoked. 
 colors, frame,rotation etc
 logging these values confirms them
 
 When I unfreeze it, well the values remain identical. hence I know the save 
 worked.
 
 I initialize the object with the decoded rectangle for the frame
 I then apply the transition to rotate it to the correct angle.
 
 hmm the result looks nothing like the initial item did at save time
 
 So I've been looking at this very closely... Is this happening because 
 simply applying the last known frame and angle does not mean it will match?
 If this is the case, does it mean then that in order to preserve the exact 
 state, I must not only save all the data about the object but an array of 
 every change made to the object such as resizes and rotations in order to 
 get the correct result?
 
 My bandaid is to convert the view in to a UIImage and save the image. This 
 fixes the problem however the downside is that special effects that can be 
 applied to rectangles and ellipses are not available on reload.
 

___

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: Malformed URL string in openURL

2011-06-07 Thread Steve Christensen
On Jun 7, 2011, at 6:32 PM, James Merkel wrote:

 On Jun 7, 2011, at 6:20 PM, Jens Alfke wrote:
 
 On Jun 7, 2011, at 6:17 PM, James Merkel wrote:
 
 The following works ok:
 
 NSString * mapquestURLString;
 
 mapquestURLString = [NSString 
 stringWithString:@http://mapq.st/?maptype=hybridq=39.7452,-104.98916;];
 
 (Just FYI, the -stringWithString call is redundant. You can just assign the 
 constant directly to the variable.)
 
 mapquestURLString = [NSString 
 stringWithString:@http://mapq.st/?maptype=hybridq=39.7452,-104.98916(Test 
 point label)”];
 
 It’s not the parens that are illegal, it’s the spaces. Change them to %20 
 and you should be OK.
 
 —Jens
 
 Right you are -- thanks.
 
 I was using stringWithString because I actually  was building  up a URL 
 string by appending strings.
 I simplified the code to show the problem.

Is there some reason you're not using built-in support to properly escape 
strings that are part of URLs?

NSString* mapType = @hybrid;
NSString* location = @39.7452,-104.98916(Test point label);

mapquestURLString = [NSString 
stringWithFormat:@http://mapq.st/?maptype=%@q=%@;,
[mapType 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
[location 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

___

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: Application Design

2011-06-01 Thread Steve Christensen
Why do you need to do any explicit cleanup on app termination? App memory 
disappears (poof!) so it's not like you're leaking anything. Is your class 
holding onto some state that must be written out to disk, for example?


On Jun 1, 2011, at 3:54 AM, Dan Hopwood wrote:

 Thanks Steve. For completeness - what's the proper way to perform the 
 cleanup? Should another static method be created that releases the singleton 
 instance when the app is closed? i.e.
 
 + (void)releaseSharedInterface
 {
 [sharedInstance release];
 sharedInsance = nil;
 }
 
 D
 
 
 On 1 June 2011 09:54, Dan Hopwood d...@biasdevelopment.com wrote:
 Great, thanks a lot Steve - very helpful.
 
 D
 
 
 
 On 31 May 2011 18:44, Steve Christensen puns...@mac.com wrote:
 How about providing a singleton class method? Then you just include 
 WebServiceInterface.h where needed. No need to have a global variable.
 
 @implementation WebServiceInterface
 
 ...
 
 + (WebServiceInterface*) sharedInterface
 {
   static WebServiceInterface* sharedInstance = nil;
 
   if (sharedInstance == nil)
   sharedInstance = [[WebServiceInterface alloc] init];
 
   return sharedInstance;
 }
 
 ...
 
 @end
 
 
 foo = [[WebServiceInterface sharedInterface] someMethod];
 
 
 On May 31, 2011, at 3:25 AM, Dan Hopwood wrote:
 
 Thanks for all your answers, they make complete sense.
 
 I have one more related question. I have developed a custom, stateful 
 WebServiceInterface object, which manages all connection requests made to an 
 XML-RPC server. Being stateful, I initialise this object when the app 
 launches and at the moment I store a pointer to it in a header file, which I 
 include in all view controllers. This allows me to make a request for data 
 from anywhere. In a similar way, I feel that storing a global pointer is not 
 best practise and can't help but think there is a more elegant way of doing 
 this. One option I have considered if storing/initialising the object in the 
 app delegate and then creating a utility method in the delegate that wraps 
 the object call. Is this the best solution or is there a design pattern I am 
 unaware of?
 
 Many thanks!
 
 
 On 28 May 2011 19:15, Conrad Shultz con...@synthetiqsolutions.com wrote:
 On May 28, 2011, at 6:11, Dan Hopwood d...@biasdevelopment.com wrote:
 
  Thanks for your response Steve. I have considered using the
  nsnotification service but what if you need to not only let another
  object know when an event has occurred but you also need to send that
  object some data? For example a user selects an option in a table -
  the selection must be conveyed in some way to the vc I'm pushing on
  the nav controller stack so that it's view is dynamic depending on the
  selection. As far as I'm aware that is not possible using
  notifications.
 
 That's very doable with notifications.  See the object and userInfo 
 methods in NSNotification and corresponding methods in NSNotificationCenter.
 
  In general I create a new vc/nib for *every* screen I have in the app.
  Let's take a navigation app as an example. Are you saying that the
  hierarchy should be:
 
  - 'root view controller' (has overall control, contains navigation
  logic and sends data between the containing view controllers)
  -- 'nav controller'
  -- 'all view controllers to be pushed/popped'
 
  ...where the nav controller and its view controllers are stored and
  initialised inside the 'root view controller'?
 
 Well, I'd say the view controllers aren't stored inside the root view 
 controller; they are pushed onto the navigation stack as and when needed. 
 Unless you are doing some caching, I wouldn't store the view controllers 
 outside the navigation stack. (If you do implement caching, make sure you 
 respond to memory warnings by flushing the cache!)
 
 In a navigation based application I feel that your architecture is 
 simplified by design.  Since only one view controller (notwithstanding modal 
 view controllers) is on screen at any time, and they are all arranged 
 hierarchically, parents should configure their children before pushing them 
 onto the stack. When children need to communicate back to their parents (for 
 example, if you push an editor view controller from a summary view 
 controller, which needs to be updated when the editor view controller makes 
 changes), you can use KVO or notifications, but if the communication is by 
 design of interest only to the parent and child view controllers, just make 
 the parent the delegate of the child. So if the child, say, had a list of 
 favorite URLs for the user to select, it could call something like [delegate 
 didSelectFavorite:url] which would cause the parent to be updated (and 
 change appearance when the child is popped off the stack).

___

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

Re: Application Design

2011-06-01 Thread Steve Christensen
Yep, that's true. I was going for the simple case since, unless you 
specifically plan to reference the singleton from multiple threads, you don't 
need to do anything more fancy.


On Jun 1, 2011, at 5:05 PM, Andrew Thompson wrote:

 I'll caution you as written that singleton is not be thread safe. Often you 
 don't care, because you only have one thread or because creating 2 webservice 
 clients may not be a problem for you. 
 
 
 On Jun 1, 2011, at 3:54 AM, Dan Hopwood d...@biasdevelopment.com wrote:
 
 Thanks Steve. For completeness - what's the proper way to perform the
 cleanup? Should another static method be created that releases the singleton
 instance when the app is closed? i.e.
 
 + (void)releaseSharedInterface
 {
   [sharedInstance release];
   sharedInsance = nil;
 }
 
 D
 
 
 On 1 June 2011 09:54, Dan Hopwood d...@biasdevelopment.com wrote:
 
 Great, thanks a lot Steve - very helpful.
 
 D
 
 
 
 On 31 May 2011 18:44, Steve Christensen puns...@mac.com wrote:
 
 How about providing a singleton class method? Then you just
 include WebServiceInterface.h where needed. No need to have a global
 variable.
 
 @implementation WebServiceInterface
 
 ...
 
 + (WebServiceInterface*) sharedInterface
 {
 static WebServiceInterface* sharedInstance = nil;
 
 if (sharedInstance == nil)
 sharedInstance = [[WebServiceInterface alloc] init];
 
 return sharedInstance;
 }
 
 ...
 
 @end
 
 
 foo = [[WebServiceInterface sharedInterface] someMethod];
 
 
 On May 31, 2011, at 3:25 AM, Dan Hopwood wrote:
 
 Thanks for all your answers, they make complete sense.
 
 I have one more related question. I have developed a custom, stateful
 WebServiceInterface object, which manages all connection requests made to 
 an
 XML-RPC server. Being stateful, I initialise this object when the app
 launches and at the moment I store a pointer to it in a header file, which 
 I
 include in all view controllers. This allows me to make a request for data
 from anywhere. In a similar way, I feel that storing a global pointer is 
 not
 best practise and can't help but think there is a more elegant way of doing
 this. One option I have considered if storing/initialising the object in 
 the
 app delegate and then creating a utility method in the delegate that wraps
 the object call. Is this the best solution or is there a design pattern I 
 am
 unaware of?
 
 Many thanks!
 
 
 On 28 May 2011 19:15, Conrad Shultz con...@synthetiqsolutions.comwrote:
 
 On May 28, 2011, at 6:11, Dan Hopwood d...@biasdevelopment.com wrote:
 
 Thanks for your response Steve. I have considered using the
 nsnotification service but what if you need to not only let another
 object know when an event has occurred but you also need to send that
 object some data? For example a user selects an option in a table -
 the selection must be conveyed in some way to the vc I'm pushing on
 the nav controller stack so that it's view is dynamic depending on the
 selection. As far as I'm aware that is not possible using
 notifications.
 
 That's very doable with notifications.  See the object and userInfo
 methods in NSNotification and corresponding methods in 
 NSNotificationCenter.
 
 In general I create a new vc/nib for *every* screen I have in the app.
 Let's take a navigation app as an example. Are you saying that the
 hierarchy should be:
 
 - 'root view controller' (has overall control, contains navigation
 logic and sends data between the containing view controllers)
 -- 'nav controller'
 -- 'all view controllers to be pushed/popped'
 
 ...where the nav controller and its view controllers are stored and
 initialised inside the 'root view controller'?
 
 Well, I'd say the view controllers aren't stored inside the root view
 controller; they are pushed onto the navigation stack as and when needed.
 Unless you are doing some caching, I wouldn't store the view controllers
 outside the navigation stack. (If you do implement caching, make sure you
 respond to memory warnings by flushing the cache!)
 
 In a navigation based application I feel that your architecture is
 simplified by design.  Since only one view controller (notwithstanding 
 modal
 view controllers) is on screen at any time, and they are all arranged
 hierarchically, parents should configure their children before pushing 
 them
 onto the stack. When children need to communicate back to their parents 
 (for
 example, if you push an editor view controller from a summary view
 controller, which needs to be updated when the editor view controller 
 makes
 changes), you can use KVO or notifications, but if the communication is by
 design of interest only to the parent and child view controllers, just 
 make
 the parent the delegate of the child. So if the child, say, had a list of
 favorite URLs for the user to select, it could call something like 
 [delegate
 didSelectFavorite:url] which would cause the parent to be updated (and
 change appearance when the child is popped off the stack

Re: Scaling a NSImage not working

2011-06-01 Thread Steve Christensen
-drawInRect draws the image into the destination rectangle, stretching or 
shrinking as necessary to get it to fit. If you want to preserve the aspect 
ratio, you'll have to generate a scaled rectangle with the image's aspect 
ratio. That's just simple math.


On Jun 1, 2011, at 9:29 PM, Development wrote:

 Ok am I barking up the wrong tree here?
 
 I know there has to be a way of taking an image of size say 128X128
 and drawing it in to a rectangle of say size 256X512
 without loosing the aspect ratio of the original image.
 
 However The following code DOES NOT DO THIS
 
 NSImage * screenImage = [[NSImage alloc]initWithCGImage:cgImage 
 size:NSMakeSize(CGImageGetWidth(cgImage), CGImageGetHeight(cgImage))];
 
NSImage * destination = [[NSImage alloc]initWithSize:movieFrame.size];
[destination lockFocus];
[[NSColor blackColor]set];
NSRectFill([destination alignmentRect]); //I want a black poster frame 
 around the image
[screenImage drawInRect:[destination alignmentRect] fromRect:[screenImage 
 alignmentRect] operation:NSCompositeSourceAtop fraction:1.0];
 
[destination unlockFocus];
 
 
 Was I completely mistaken in thinking that the way I'm doing this was suppose 
 to preserve the aspect ratio?
 Is it even possible to do what I'm trying to do? (I know the answer is yes 
 since I've seen it done.)
 
 Am I going to have to do this at the CGImage level?
 
 Some kind of information would be nice google is a bust, cannot find the 
 information on the developer site.
 All the examples I have seen assume the source and destination images are the 
 same size
 However as I explained before, the user is able to select specific areas in 
 the capture view to focus on.  And since the selections never have the same 
 aspect ratio as the destination, when I try to draw the image it's distorted. 

___

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: Application Design

2011-05-31 Thread Steve Christensen
How about providing a singleton class method? Then you just include 
WebServiceInterface.h where needed. No need to have a global variable.

@implementation WebServiceInterface

...

+ (WebServiceInterface*) sharedInterface
{
static WebServiceInterface* sharedInstance = nil;

if (sharedInstance == nil)
sharedInstance = [[WebServiceInterface alloc] init];

return sharedInstance;
}

...

@end


foo = [[WebServiceInterface sharedInterface] someMethod];


On May 31, 2011, at 3:25 AM, Dan Hopwood wrote:

 Thanks for all your answers, they make complete sense.
 
 I have one more related question. I have developed a custom, stateful 
 WebServiceInterface object, which manages all connection requests made to an 
 XML-RPC server. Being stateful, I initialise this object when the app 
 launches and at the moment I store a pointer to it in a header file, which I 
 include in all view controllers. This allows me to make a request for data 
 from anywhere. In a similar way, I feel that storing a global pointer is not 
 best practise and can't help but think there is a more elegant way of doing 
 this. One option I have considered if storing/initialising the object in the 
 app delegate and then creating a utility method in the delegate that wraps 
 the object call. Is this the best solution or is there a design pattern I am 
 unaware of?
 
 Many thanks!
 
 
 On 28 May 2011 19:15, Conrad Shultz con...@synthetiqsolutions.com wrote:
 On May 28, 2011, at 6:11, Dan Hopwood d...@biasdevelopment.com wrote:
 
  Thanks for your response Steve. I have considered using the
  nsnotification service but what if you need to not only let another
  object know when an event has occurred but you also need to send that
  object some data? For example a user selects an option in a table -
  the selection must be conveyed in some way to the vc I'm pushing on
  the nav controller stack so that it's view is dynamic depending on the
  selection. As far as I'm aware that is not possible using
  notifications.
 
 That's very doable with notifications.  See the object and userInfo 
 methods in NSNotification and corresponding methods in NSNotificationCenter.
 
  In general I create a new vc/nib for *every* screen I have in the app.
  Let's take a navigation app as an example. Are you saying that the
  hierarchy should be:
 
  - 'root view controller' (has overall control, contains navigation
  logic and sends data between the containing view controllers)
  -- 'nav controller'
  -- 'all view controllers to be pushed/popped'
 
  ...where the nav controller and its view controllers are stored and
  initialised inside the 'root view controller'?
 
 Well, I'd say the view controllers aren't stored inside the root view 
 controller; they are pushed onto the navigation stack as and when needed. 
 Unless you are doing some caching, I wouldn't store the view controllers 
 outside the navigation stack. (If you do implement caching, make sure you 
 respond to memory warnings by flushing the cache!)
 
 In a navigation based application I feel that your architecture is simplified 
 by design.  Since only one view controller (notwithstanding modal view 
 controllers) is on screen at any time, and they are all arranged 
 hierarchically, parents should configure their children before pushing them 
 onto the stack. When children need to communicate back to their parents (for 
 example, if you push an editor view controller from a summary view 
 controller, which needs to be updated when the editor view controller makes 
 changes), you can use KVO or notifications, but if the communication is by 
 design of interest only to the parent and child view controllers, just make 
 the parent the delegate of the child. So if the child, say, had a list of 
 favorite URLs for the user to select, it could call something like [delegate 
 didSelectFavorite:url] which would cause the parent to be updated (and change 
 appearance when the child is popped off the stack).

___

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: Application Design

2011-05-27 Thread Steve Christensen
A view controller controls a specific view hierarchy so it shouldn't be 
reaching explicitly out to other view controllers to tell them to do something.

Depending on your specific situation, interested objects could register for 
notifications when certain things change in the world, then one object could 
just broadcast that something changed and not worry about what other objects 
care. Or you could synch a controller's state (and possibly its view(s)) in its 
-viewWillAppear: method since in many cases only a single controller's view 
hierarchy is visible at any one time.


On May 27, 2011, at 11:13 AM, Dan Hopwood wrote:

 I have been writing iPhone applications for a while now, with not too many
 problems but I feel like I haven't fully grasped how an application should
 be structured in terms of storing application objects. e.g. up to now, I've
 created a header file, declared all the main objects e.g. app delegate, view
 controllers, utilities and initialised them in the app delegate. For each
 class, I then just include the header file, which gives me access to all the
 objects, should I need to send them messages on certain UI events.
 
 Another option I have considered is storing them all in the app delegate
 instead and creating utility methods in the app delegate that delegate out
 to the objects from one place. E.g. a VC would then call the app delegate
 each time it needs to interact with another VC.
 
 If neither of these options is valid, which I suspect is the case (certainly
 global pointers is considered to be bad practise), then how do you store
 these pointers to that they are accessible in some way by all the VCs.
 Sending in the required pointers on initialisation of each VC (and storing a
 copy in each class) is the only other option I can think of but this seems
 annoyingly unelegant.
 
 Thoughts and suggestions much appreciated.

___

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: Drawing an arc fill inside an image

2011-05-26 Thread Steve Christensen
Custom view that sits on top of a UIImageView? Implement -drawRect: and a 
progress property and you're done.


On May 26, 2011, at 11:21 AM, Alex Kac wrote:

 I'm not sure what the best way to tackle this is... so I thought I'd ask 
 here. I have an image with a circular button inside of it. I'd like to 
 dynamically fill this button in an arc to show progress much like how when 
 you are on iTunes Store on an iOS and its playing the preview its animating 
 filling the circle in a sweep of an arc. Mine doesn't need to animate however.
 
 So I have the image, and I suppose I can draw that image to a context and 
 then draw an arc on that image, and then make another image out of it. That 
 seems like it would get slow if I needed to do that a lot. Any suggestions? I 
 also wouldn't mind any links that might show similar code. This is for iOS. I 
 tried searching Google, but my GoogleFu is not showing anything, probably due 
 to me not using the right terms.

___

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 nib weirdness...

2011-05-06 Thread Steve Christensen
Just to provide closure on this thread, I believe I figured out what was 
happening although not why nor who the exact culprit was.

To summarize, all the pieces were set up correctly. The nib file was being 
compiled in response to changes. The problem appears to be that at some point 
it stopped being copied into the simulator as part of running it in the 
debugger. I'm not sure if it was Xcode, the simulator or what. I ended up 
deleting the app from the simulator, rebuilding everything, and haven't seen 
the problem since. Very strange and something I haven't run into before.


On May 4, 2011, at 7:00 AM, Steve Christensen wrote:

 I'm working on an app that uses a tab bar. I created a new nib to set up a 
 view+controller and added a new tab item to the main nib that references the 
 controller and the controller's nib, plus I filled in some basic 
 functionality in the view controller. Since it's relevant, the controller's 
 IBOutlets are
 
 IBOutlet MyTableView* _resultsTable;
 IBOutlet UIActivityIndicatorView* _searchActivityIndicator;
 IBOutlet UISearchBar* _searchBar;
 
 When I ran the app and used the new view's UI, I got an unexpected 
 unrecognized selector exception when trying to access a custom method in 
 _resultsTable. When I looked at their values in the debugger, I found that 
 _resultsTable was an instance of UITableView, not MyTableView; and 
 _searchActivityIndicator and _searchBar were both nil.
 
 I thought that there could be a missing class issue, but the MyTableView 
 class is implemented since creating a test MyTableView instance in code works 
 just fine. That still doesn't explain the other nil values since all three 
 views were wired up in IB: the view controller shows the views connected to 
 the outlets and the views show themselves as connected.
 
 Grasping at straws, I trashed the build results and did a clean build, and 
 even re-launched Xcode, with no difference in behavior. I could very well be 
 doing something dumb but I'm not exactly sure where to look since I've 
 (correctly) set up this same sort of thing before and it worked fine. BTW, 
 I'm using Xcode 3.2.6 + iOS SDK 4.3. Any ideas?
 
 steve

___

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


iOS nib weirdness...

2011-05-04 Thread Steve Christensen
I'm working on an app that uses a tab bar. I created a new nib to set up a 
view+controller and added a new tab item to the main nib that references the 
controller and the controller's nib, plus I filled in some basic functionality 
in the view controller. Since it's relevant, the controller's IBOutlets are

IBOutlet MyTableView* _resultsTable;
IBOutlet UIActivityIndicatorView* _searchActivityIndicator;
IBOutlet UISearchBar* _searchBar;

When I ran the app and used the new view's UI, I got an unexpected 
unrecognized selector exception when trying to access a custom method in 
_resultsTable. When I looked at their values in the debugger, I found that 
_resultsTable was an instance of UITableView, not MyTableView; and 
_searchActivityIndicator and _searchBar were both nil.

I thought that there could be a missing class issue, but the MyTableView class 
is implemented since creating a test MyTableView instance in code works just 
fine. That still doesn't explain the other nil values since all three views 
were wired up in IB: the view controller shows the views connected to the 
outlets and the views show themselves as connected.

Grasping at straws, I trashed the build results and did a clean build, and even 
re-launched Xcode, with no difference in behavior. I could very well be doing 
something dumb but I'm not exactly sure where to look since I've (correctly) 
set up this same sort of thing before and it worked fine. BTW, I'm using Xcode 
3.2.6 + iOS SDK 4.3. Any ideas?

steve

___

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: L-shaped custom view in Cocoa?

2011-05-04 Thread Steve Christensen
All views are rectangular in shape. You can restrict drawing and responding to 
events to an L-shaped area, but the view itself will still be a rectangle.


On May 4, 2011, at 6:41 AM, Vyacheslav Karamov wrote:

 I need to make custom view in the form of letter L. How to do it?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


  1   2   3   >