Show count of Core Data to-many relationship in NSTableView cell with bindings?

2015-02-05 Thread Steve Mills
I have a Core Data entity called Keyword that has a to-many relationship to 
another entity called Image. In a table that displays these Keywords, I want 
one column to show the number of Images that use that particular Keyword. I 
tried setting the Value binding for the Table View Cell to bind to the Table 
Cell View with model key path of objectValue.images.count. That doesn't work - 
throws an exception:

[_NSFaultingMutableSet 0x620246e0 
addObserver:forKeyPath:options:context:] is not supported. Key path: count

Is it not possible to bind to an entity's relationship properties? The Keyword 
class has a property named assets of class NSSet, so it seems like the binding 
should be able to access it just like the attribute properties.

--
Steve Mills
Drummer, Mac geek


___

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: Show count of Core Data to-many relationship in NSTableView cell with bindings?

2015-02-05 Thread Quincey Morris
On Feb 5, 2015, at 23:43 , Steve Mills sjmi...@mac.com wrote:
 
 [_NSFaultingMutableSet 0x620246e0 
 addObserver:forKeyPath:options:context:] is not supported. Key path: count
 
 Is it not possible to bind to an entity's relationship properties?

You can’t bind *through* an array or set collection class. However, you can use 
these:


https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/KeyValueCoding/Articles/CollectionOperators.html
 
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/KeyValueCoding/Articles/CollectionOperators.html



___

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

-windowdidLoad

2015-02-05 Thread Raglan T. Tiger
What does [super windowDidLoad} accomplish in the subclass implementation of 
-windowDidLoad and is it necessary?

-rags




___

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: NSCalendar and NSDates prior to October 15, 1582

2015-02-05 Thread Jeffrey Oleander

On 2015 Jan 30, at 12:32, Steve Mykytyn wrote:
The documentation for the Date and Time Programming Guide for iOS does  
not seem to be telling the truth, or perhaps I'm doing something  
wrong.


From
https://developer.apple.com/library/ios/documentation/Cocoa/ 
Conceptual/DatesAndTimes/Articles/dtHist.html


The Julian to Gregorian Transition

NSCalendar models the transition from the Julian to Gregorian calendar  
in October 1582. During this transition, 10 days were skipped. This  
means that October 15, 1582 follows October 4, 1582. All of the  
provided methods for calendrical calculations take this into account,  
but you may need to account for it when you are creating dates from  
components. Dates created in the gap are pushed forward by 10 days.  
For example October 8, 1582 is

stored as October 18, 1582.

...

In reality it's not so simple; calendar/date designations, because of  
the non-integer and varying spin, orbits (365.22... or maybe  
365.2425... day year), etc., religion and what have you (calendars  
which use leap seconds, leap days, leap months...), are never as simple  
as most of us believe they SHOULD be.


Some countries did not adopt the Gregorian adjustment until the 1750s,  
and others much later than that (Russia partially converted in 1700 but  
not completely until 1922, Turkey in 1926).  Anyway, it's not something  
you can do a neat mathematical conversion on and have it work  
perfectly everywhere and for every date.   What of those of us who  
have to deal with dates going back to e.g. 1200BCE?


But then are we talking calendar conversion, date conversion, or merely  
date formatting?


http://www.adamsonancestry.com/calendar/
http://www.adamsonancestry.com/pioneering_spirit/#_Toc302021234

https://en.wikipedia.org/wiki/Old_Style_and_New_Style_dates

http://galileo.rice.edu/chron/gregorian.html

http://www.britannica.com/EBchecked/topic/245469/Gregorian-calendar
http://www.britannica.com/EBchecked/topic/307826/Julian-calendar

http://scienceworld.wolfram.com/astronomy/GregorianCalendar.html

http://stackoverflow.com/questions/20446495/conversion-of-nsstring-to- 
nsdate-conversion-incorrect-result
http://stackoverflow.com/questions/141315/php-check-for-a-valid-date- 
weird-date-conversions
http://stackoverflow.com/questions/2140597/client-side-date- 
conversions-in-gwt


http://www.cocoawithlove.com/2008/10/worldtimeconverter-dates-and- 
timezones.html


http://www.codeproject.com/Articles/2730/Gregorian-Date-To-ISO-Date- 
Converter


http://forum.ionicframework.com/t/problem-with-conversion-of-specific- 
dates-on-ios/16689


And a slew of books, and several videos on the topic turned up when I  
did an ixquick.
_Demystifying the Gregorian Calendar: A Look into Its History and the  
Math Behind It_  Paperback -- 2014 April 7 by Walter A. Calhoon

_Gregorian Calendar_ [Kindle Edition] by Merv Astle
_The Calendar (Inventions That Shaped the World)_  Paperback -- 2005  
September 1  by   Patricia K. Kummer
_Calendar Fraud_ [Kindle Edition] by Laura Lee Vornholt-Jones, Elaine  
Vornholt, Brad Vornholt...


(And why doesn't Numbers have TSV as an export option?!  It's more  
cleanly portable than CSV... and why are the marketing promo examples  
so overly simplistic?)

___

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: Networking framework crash

2015-02-05 Thread Roland King

 
 Everything is a file descriptor. Open files, sockets, loaded frameworks  
 bundles, even STDIN/OUT/ERROR.
 
 You can check if you're hitting the limit of file descriptors by 
 (temporarily) raising the number you can have open with setrlimit(). If you 
 raise it and your app stops crashing, then that's likely the culprit. I would 
 guess so - the default max number you can have open is 256, and 0xfe lines up 
 with that...
 
 If your app runs long enough before crashing, you can also use lsof in 
 Terminal to see what your app has open.
 


Where do you get 256 from? I just inserted the following two lines of code into 
a random OSX GUI app and a command line tool I wrote, right after launch

struct rlimit file_limit;
getrlimit( RLIMIT_NOFILE, file_limit );

For the GUI app I get

file_limit.rlim_cur = 9472

and for the command line I get

file_limit.rlim_cur = 7168

when run from Xcode or 2560 in either case when run from the command line or 
double-clicked from the finder. 

all of which seems to indicate processes have plenty more than 256 file 
descriptors available by default. I thought 256 was left behind as a default 
long ago because it was way too small. 

If I’m in a bash shell and run 

ulimit -n 

I get 2560

launchctl limit shows 

maxfiles256unlimited   

That’s the only place I can find 256 and I don’t know when that is used. 

Finally 

sysctl kern.maxfilesperproc

returns 10240 which I think is the absolute hard limit on the number of file 
handles any process can have available. 





___

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: Networking framework crash

2015-02-05 Thread Michael Nickerson

 On Feb 4, 2015, at 9:49 PM, Graham Cox graham@bigpond.com wrote:
 On 5 Feb 2015, at 12:20 pm, Roland King r...@rols.org wrote:
 
 You should google EXC_GUARD, it’s interesting. 
 
 0x400200fe
 
 the 02 in the middle says the guard is in dup(), which it is. The 0xfe at 
 the end tells you what file descriptor it’s on. (0xfe .. really, seems 
 unusually if not impossibly large for a file descriptor, you got that many 
 files open?).
 
 
 Well, at the point where this crashes, I haven't opened any files at all 
 myself, though it partly depends what you mean by file in this context, and 
 whether the lower level code invoked by NSURLSession opens files for its own 
 use. As I said, I'm creating about 50 NSURLSessions as my app launches, which 
 may be simply too many.
 
 I am googling EXC_GUARD but haven't found anything that breaks it down - just 
 a bunch of people asking what it is.

Everything is a file descriptor. Open files, sockets, loaded frameworks  
bundles, even STDIN/OUT/ERROR.

You can check if you're hitting the limit of file descriptors by (temporarily) 
raising the number you can have open with setrlimit(). If you raise it and your 
app stops crashing, then that's likely the culprit. I would guess so - the 
default max number you can have open is 256, and 0xfe lines up with that...

If your app runs long enough before crashing, you can also use lsof in Terminal 
to see what your app has open.




Michael Nickerson
___

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: -windowdidLoad

2015-02-05 Thread Quincey Morris
On Feb 5, 2015, at 13:13 , Raglan T. Tiger r...@crusaderrabbit.net wrote:
 
 What does [super windowDidLoad} accomplish in the subclass implementation of 
 -windowDidLoad and is it necessary?

If “the subclass” is a direct subclass of NSWindowController, then it does what 
the NSWindowController class reference says it does:

 The default implementation does nothing.”


However, it’s possible you might insert another class between the subclass and 
the base class in the future, and invoking the ‘super’ method protects you 
against inadvertently creating a bug when doing so.

Also, more or less the same point, it relieves your subclass from knowing 
exactly what it’s a subclass of.


___

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: Self describing NSObjects.

2015-02-05 Thread Seth Willits
On Feb 4, 2015, at 10:43 AM, Alex Zavatone z...@mac.com wrote:
 
 How would you think about implementing this?  It seems like I run into this 
 need year after year after year.


NSString * NSObjectDescriptionUsingProperties(id obj)
{
unsigned int propCount;
objc_property_t * propList = class_copyPropertyList([obj class], 
propCount);
NSMutableString * ms = [NSMutableString stringWithFormat:@%@: %p, 
NSStringFromClass([obj class]), obj];
if (propCount  0) {
[ms appendString:@ {\n];
for (unsigned int i = 0; i  propCount; i++) {
const char * propName = property_getName(propList[i]);
[ms appendFormat:@\t%s = %@,\n, propName, [obj 
valueForKey:[NSString stringWithUTF8String:propName]]];
}
[ms appendString:@}];
free(propList);
}

return ms;
}




--
Seth Willits




___

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: Networking framework crash

2015-02-05 Thread Graham Cox

 On 6 Feb 2015, at 6:48 am, Greg Parker gpar...@apple.com wrote:
 
 You can use getrlimit(RLIMIT_NOFILE, …) to query the limit in your process, 
 and setrlimit(RLIMIT_NOFILE, …) to attempt to raise it. The default limit may 
 be as low as 256, depending on OS version and on how the process is launched. 
 (Note that each two-way network connection uses two file descriptors.) 
 setrlimit() should be able to raise the file descriptor limit to a few 
 thousand unless your system administrator is mean.


This is great. Running from XCode I get 7168, archiving and exporting a final 
build of my app, I get 256... bingo! Only the built version was seeing this 
crash, another reason I was having a lot of trouble debugging it.

With 50 tasks, creating 50 NSURLSession, that accounts for 100 file 
descriptors. I'm supposing the rest come from other places - in fact each of my 
tasks potentially creates 2 NSURLSession, though these second ones are highly 
conditional on what the first ones return, and usually are NOT created, so I 
doubt that I was immediately creating 200 file handles.

I've redesigned part of my app so that a shared NSURLSession is used across all 
tasks for the first type of session, leaving the individual sessions for the 
second type, which are architecturally unrelated to the first kind and created 
by a completely different object, so that should help a lot in the first place. 
I will also up the filehandle limit to give it a bit more headroom - I would 
imagine in practice that 50 tasks is a reasonable upper limit that the user 
would create - I can add some constraints on that in my UI.


 
 If you hit that limit you should see errors from various network API. File a 
 bug report if you find some API that causing weird crashes instead of failing 
 gracefully or halting with an appropriate error message when you run out of 
 file descriptors.

Well I'm seeing EXC_GUARD. Is that considered graceful? From the user's 
perspective it isn't, because it causes summary termination of the app which is 
almost always reported as it crashed, wah!, you suck!. Ultimately this should 
propagate up to the NSURLSession API in some way - e.g. by returning nil 
instead of an object if it can't create its resources. I think one problem 
there is that the API is asynchronous - it creates the object which then starts 
a thread to open the socket - that's what the stack trace implies anyway. That 
would make it hard to simply not return a valid object. Not sure what the right 
design would be there - that's one for the networking architects to ponder I 
guess.

Anyway, thanks for everyone's replies - I have gained a lot of insight into 
things that I didn't have before - I haven't done much network stuff before.

--Graham
___

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: Self describing NSObjects.

2015-02-05 Thread Shazron
Similar to Seth's method:
https://github.com/phonegap/adobe-creative-sdk-foundation/blob/master/src/ios/NSObject%2BPropertiesAsDictionary.m
Then you could serialize the dictionary to a JSON string, and print that.

On Thu, Feb 5, 2015 at 3:54 PM, Seth Willits sli...@araelium.com wrote:
 On Feb 4, 2015, at 10:43 AM, Alex Zavatone z...@mac.com wrote:

 How would you think about implementing this?  It seems like I run into this 
 need year after year after year.


 NSString * NSObjectDescriptionUsingProperties(id obj)
 {
 unsigned int propCount;
 objc_property_t * propList = class_copyPropertyList([obj class], 
 propCount);
 NSMutableString * ms = [NSMutableString stringWithFormat:@%@: %p, 
 NSStringFromClass([obj class]), obj];
 if (propCount  0) {
 [ms appendString:@ {\n];
 for (unsigned int i = 0; i  propCount; i++) {
 const char * propName = property_getName(propList[i]);
 [ms appendFormat:@\t%s = %@,\n, propName, [obj 
 valueForKey:[NSString stringWithUTF8String:propName]]];
 }
 [ms appendString:@}];
 free(propList);
 }

 return ms;
 }




 --
 Seth Willits




 ___

 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/shazron%40gmail.com

 This email sent to shaz...@gmail.com
___

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

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

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

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

Re: Networking framework crash

2015-02-05 Thread Roland King
 
 
 If you hit that limit you should see errors from various network API. File a 
 bug report if you find some API that causing weird crashes instead of 
 failing gracefully or halting with an appropriate error message when you run 
 out of file descriptors.
 
 Well I'm seeing EXC_GUARD. Is that considered graceful? From the user's 
 perspective it isn't, because it causes summary termination of the app which 
 is almost always reported as it crashed, wah!, you suck!. Ultimately this 
 should propagate up to the NSURLSession API in some way - e.g. by returning 
 nil instead of an object if it can't create its resources. I think one 
 problem there is that the API is asynchronous - it creates the object which 
 then starts a thread to open the socket - that's what the stack trace implies 
 anyway. That would make it hard to simply not return a valid object. Not sure 
 what the right design would be there - that's one for the networking 
 architects to ponder I guess.
 

I don’t think that’s very graceful, no. Since the only ‘documentation’ on 
EXC_GUARD seems to be in the replies in devforums it’s hard to say exactly what 
the contract is. However that reply, to my reading, indicates means someone 
called a normal filehandle method on a guarded filehandle, ie violating the 
guard. The header file says this

#define EXC_GUARD   12  /* Violated guarded resource 
protections */

Whereas what you seem to have here is ‘filesystem call to a guarded resource 
failed in some normal way I could have reported properly’. 

Yes you’re out of filehandles and so there’s a failure, would have been much 
more useful to have the original failure code logged [EMFILE] than EXC_GUARD 
which (again to my reading) means something entirely different and is 
misleading. So I’d file a bug against that one. 

By the way - where do all these disparate max numbers of filehandles come from? 
I see the launchd one, makes sense, stuff launched from bash inherits bash’s 
2560, stuff launched from finder on my box also gets 2560 (why), Xcode has its 
own ideas, which I suppose makes some sense as debugged processes probably need 
more handles and whatever Graham did to launch his process in this case got 
256, which I haven’t yet found a way to get a process on 10.10 to do by default 
yet barring making launchd launch it. 


___

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

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

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

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

Re: Networking framework crash

2015-02-05 Thread Graham Cox

 On 6 Feb 2015, at 11:18 am, Roland King r...@rols.org wrote:
 
 whatever Graham did to launch his process in this case got 256, which I 
 haven’t yet found a way to get a process on 10.10 to do by default yet 
 barring making launchd launch it.


I simply double-clicked it in the Finder. This is on 10.10.2. Other than 
whatever Xcode does when you give it permission to allow the machine to be a 
development machine, I would say it's as standard as they come.

--Graham



___

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: Self describing NSObjects.

2015-02-05 Thread Seth Willits
On Feb 5, 2015, at 3:54 PM, Seth Willits sli...@araelium.com wrote:

 How would you think about implementing this?  It seems like I run into this 
 need year after year after year.
 
 
 NSString * NSObjectDescriptionUsingProperties(id obj)
 {
   unsigned int propCount;
   objc_property_t * propList = class_copyPropertyList([obj class], 
 propCount);
   NSMutableString * ms = [NSMutableString stringWithFormat:@%@: %p, 
 NSStringFromClass([obj class]), obj];
   if (propCount  0) {
   [ms appendString:@ {\n];
   for (unsigned int i = 0; i  propCount; i++) {
   const char * propName = property_getName(propList[i]);
   [ms appendFormat:@\t%s = %@,\n, propName, [obj 
 valueForKey:[NSString stringWithUTF8String:propName]]];
   }
   [ms appendString:@}];
   free(propList);
   }
   
   return ms;
 }
 


And if you want to get really creative, you could swizzle NSObject's 
-description to call it.



--
Seth Willits




___

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: Networking framework crash

2015-02-05 Thread Greg Parker

 On Feb 5, 2015, at 3:54 PM, Graham Cox graham@bigpond.com wrote:
 
 This is great. Running from XCode I get 7168, archiving and exporting a final 
 build of my app, I get 256... bingo! Only the built version was seeing this 
 crash, another reason I was having a lot of trouble debugging it.
 
 With 50 tasks, creating 50 NSURLSession, that accounts for 100 file 
 descriptors. I'm supposing the rest come from other places - in fact each of 
 my tasks potentially creates 2 NSURLSession, though these second ones are 
 highly conditional on what the first ones return, and usually are NOT 
 created, so I doubt that I was immediately creating 200 file handles.

You can use `sudo lsof -p PID -a -d 0-9` to list the file descriptors in 
a process. (The `-d 0-9` flag hides open files that don't have file 
descriptors.)


 If you hit that limit you should see errors from various network API. File a 
 bug report if you find some API that causing weird crashes instead of 
 failing gracefully or halting with an appropriate error message when you run 
 out of file descriptors.
 
 Well I'm seeing EXC_GUARD. Is that considered graceful? From the user's 
 perspective it isn't, because it causes summary termination of the app which 
 is almost always reported as it crashed, wah!, you suck!. Ultimately this 
 should propagate up to the NSURLSession API in some way - e.g. by returning 
 nil instead of an object if it can't create its resources. I think one 
 problem there is that the API is asynchronous - it creates the object which 
 then starts a thread to open the socket - that's what the stack trace implies 
 anyway. That would make it hard to simply not return a valid object. Not sure 
 what the right design would be there - that's one for the networking 
 architects to ponder I guess.

EXC_GUARD is very bad, usually on the order of use-after-free bad. Acceptable 
results are an error or exception from the API, preferably one that says too 
many open files, or a crash log that says too many open files. Anything that 
doesn't say too many open files somewhere is hard to diagnose.


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

Re: Networking framework crash

2015-02-05 Thread Kyle Sluder
On Thu, Feb 5, 2015, at 05:54 PM, Graham Cox wrote:
 
  On 6 Feb 2015, at 6:48 am, Greg Parker gpar...@apple.com wrote:
  
  You can use getrlimit(RLIMIT_NOFILE, …) to query the limit in your process, 
  and setrlimit(RLIMIT_NOFILE, …) to attempt to raise it. The default limit 
  may be as low as 256, depending on OS version and on how the process is 
  launched. (Note that each two-way network connection uses two file 
  descriptors.) setrlimit() should be able to raise the file descriptor limit 
  to a few thousand unless your system administrator is mean.
 
 
 This is great. Running from XCode I get 7168, archiving and exporting a
 final build of my app, I get 256... bingo! Only the built version was
 seeing this crash, another reason I was having a lot of trouble debugging
 it.


I'm not a Core OS engineer, so I have no idea how practical this is, but
I'd file a quick enhancement request anyway asking that Xcode spawn apps
in an uncustomized environment.

--Kyle

___

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: Networking framework crash

2015-02-05 Thread Roland King

 On 6 Feb 2015, at 8:29 am, Graham Cox graham@bigpond.com wrote:
 
 
 On 6 Feb 2015, at 11:18 am, Roland King r...@rols.org wrote:
 
 whatever Graham did to launch his process in this case got 256, which I 
 haven’t yet found a way to get a process on 10.10 to do by default yet 
 barring making launchd launch it.
 
 
 I simply double-clicked it in the Finder. This is on 10.10.2. Other than 
 whatever Xcode does when you give it permission to allow the machine to be a 
 development machine, I would say it's as standard as they come.
 
 --Graham
 
 

So did I, and I’m on 10.2.2 as well, and I got 2560 for both GUI and command 
line. Wonder what I did different .. perhaps it was a debug build, don’t 
remember, it was late, I shall try it again later. 
___

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: Networking framework crash

2015-02-05 Thread Michael Nickerson

 On Feb 5, 2015, at 10:22 AM, Roland King r...@rols.org wrote:
 
 
 
 Everything is a file descriptor. Open files, sockets, loaded frameworks  
 bundles, even STDIN/OUT/ERROR.
 
 You can check if you're hitting the limit of file descriptors by 
 (temporarily) raising the number you can have open with setrlimit(). If you 
 raise it and your app stops crashing, then that's likely the culprit. I 
 would guess so - the default max number you can have open is 256, and 0xfe 
 lines up with that...
 
 If your app runs long enough before crashing, you can also use lsof in 
 Terminal to see what your app has open.
 
 
 Where do you get 256 from? I just inserted the following two lines of code 
 into a random OSX GUI app and a command line tool I wrote, right after launch
 
   struct rlimit file_limit;
   getrlimit( RLIMIT_NOFILE, file_limit );
 
 For the GUI app I get
 
   file_limit.rlim_cur = 9472
 
 and for the command line I get
 
   file_limit.rlim_cur = 7168
 
 when run from Xcode or 2560 in either case when run from the command line or 
 double-clicked from the finder. 
 

Well, that'll teach me to double check before posting. I hadn't realized the 
max got upped. Seems like it's 2560 (I would guess it's higher when run in 
Xcode for debugging).


 all of which seems to indicate processes have plenty more than 256 file 
 descriptors available by default. I thought 256 was left behind as a default 
 long ago because it was way too small. 
 

Makes sense to me. I have run up against the max open files limit before when 
it was still 256. I am happy to see it was raised.


 launchctl limit shows 
 
 maxfiles256unlimited   
 
 That’s the only place I can find 256 and I don’t know when that is used.
 

So, I take the above back - not running into the limit, unless maybe it's being 
run by launchd. Those limits shown by launchctl are what's used by anything 
launchd launches, unless the plist file overrides them. I wonder if that's on 
purpose or just an oversight?


And yes, I tested that this time! I get:

Feb  5 11:16:46.875 test[4252]: cur: 2560
Feb  5 11:18:00.078 test[4274]: cur: 256

(First is normal run, second is launched by launchd.)



Michael Nickerson



___

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: dealloc query for NSTableCellView

2015-02-05 Thread Corbin Dunn

 On Feb 4, 2015, at 5:43 AM, Jonathan Mitchell jonat...@mugginsoft.com wrote:
 
 
 On 4 Feb 2015, at 13:27, Roland King r...@rols.org wrote:
 
 If I have an observation pattern which is set up, and the previous one torn 
 down, in setXXX:(id)xxx like you do then my dealloc usually goes
 
 [ self setXXX:nil ]
 
 which both removes the observers and sets the property to nil so it doesn’t 
 happen again. 
 
 Your problem here seems to be that you’ve tied the property to the observers 
 in the set, but you are removing the observers without nil’ing the property 
 in dealloc, thus leaving yourself open to another setter getting called. 
 Thanks.
 
 That approach does work in this case.
 I don’t particularly like it in general because (in the more generic 
 NSViewController case) it calls back into a core method generally used to 
 help setup an instance.
 Calling this in a habitual sense from -dealloc feels sort of wrong!
 
 
 
 Crucially I find that in this case after my subclass -dealloc the 
 superclass -dealloc calls -setObjectValue : nil which causes observation 
 warnings to be issued (I always try and clear these types of issues because 
 at the very least they mask real problems) as _objectValue will still be 
 non nil and [self removeObservers] gets called again.
 
 
 Is it normal for superclasses to message during dealloc?
 
 I would still like to know what people’s expectations are here.

It is quite normal and done in a lot of places. 

FWIW, NSTableCellView’s dealloc looks like this:

- (void)dealloc {
self.objectValue = nil;
self.imageView = nil;
self.textField = nil;
[_aux release];
[super dealloc];
}

All the properties are @synthesized.

corbin


 
 Thanks
 
 J
 
 
 ___
 
 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/corbind%40apple.com
 
 This email sent to corb...@apple.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: Networking framework crash

2015-02-05 Thread Jens Alfke

 On Feb 5, 2015, at 7:22 AM, Roland King r...@rols.org wrote:
 
 all of which seems to indicate processes have plenty more than 256 file 
 descriptors available by default. I thought 256 was left behind as a default 
 long ago because it was way too small. 

It was definitely 256 as recently as OS X 10.8 — I know because in 2012 I was 
porting a server app that needed way more file descriptors than that, so I had 
to work with setrlimit to raise it. So it must have been raised in 10.9 or 
10.10. Good.

—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: Networking framework crash

2015-02-05 Thread Kyle Sluder
On Thu, Feb 5, 2015, at 06:40 PM, Roland King wrote:
 
  On 6 Feb 2015, at 8:29 am, Graham Cox graham@bigpond.com wrote:
  
  
  On 6 Feb 2015, at 11:18 am, Roland King r...@rols.org wrote:
  
  whatever Graham did to launch his process in this case got 256, which I 
  haven’t yet found a way to get a process on 10.10 to do by default yet 
  barring making launchd launch it.

Have you installed Server.app (or upgraded from OS X Server)?

--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/archive%40mail-archive.com

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

Re: Networking framework crash

2015-02-05 Thread Roland King

 
 Yep, I found that just after I sent my previous. Interesting, though a little 
 difficult to relate exactly to my crash. I guess tcp_connection_get_socket() 
 creates a file handle for the socket stream (?? guessing) and that's the one 
 tripping the EXC_GUARD.
 
 Do you or anyone else know if there's some inherent limit to the number of 
 simultaneous sockets that can be opened? I'm supposing that there's a 1:1 
 correspondence between a NSURLSession and a socket, because of the 
 description against [NSURLSession resetWithCompletionHandler:] says:

Yes there is an inherent limit to the number of sockets which can be opened.
It's limited by the number of filehandles you can have open which you fin by 
running ulimit -n and on my machine that gives 2560 when run from a shell (oh 
how things have changed!), so you're probably not running into that. 

I really can't decide whether the filehandle you're getting the exception on, 
254, is high or not. You have probably 50 sockets open but I have no idea how 
many filehandles a generic process 'just uses' in the course of being a generic 
process. Since OSX doesn't have a /proc filesystem, it's not that easy to tell. 

 
 This method empties all cookies, caches and credential stores, removes disk 
 files, flushes in-progress downloads to disk, and ensures that future 
 requests occur on a new socket
 
 This implies that there's a socket associated with the session.
 
 Since I have also a 1:1 correspondence between my app's individual tasks and 
 NSURLSession, I'm opening 1 socket per task as my app starts. So around 50 in 
 my current test situation.
 
 
 if you aren’t opening your own files/creating your own filehandles I suspect 
 you have a bugreport in your future. 
 
 You might also try a post in CoreOS on devforums or on the networking apple 
 mail list as that’s where Quinn hangs out. 
 
 
 That sounds like a good thing to try.
 
 --Graham
 
 


___

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: Networking framework crash

2015-02-05 Thread Greg Parker

 On Feb 4, 2015, at 8:21 PM, Graham Cox graham@bigpond.com wrote:
 
 Do you or anyone else know if there's some inherent limit to the number of 
 simultaneous sockets that can be opened? I'm supposing that there's a 1:1 
 correspondence between a NSURLSession and a socket, because of the 
 description against [NSURLSession resetWithCompletionHandler:] says:
 
 This method empties all cookies, caches and credential stores, removes disk 
 files, flushes in-progress downloads to disk, and ensures that future 
 requests occur on a new socket
 
 This implies that there's a socket associated with the session.

Network connections use sockets. Sockets use file descriptors. There is a 
per-process limit on the number of open file descriptors. 

You can use getrlimit(RLIMIT_NOFILE, …) to query the limit in your process, and 
setrlimit(RLIMIT_NOFILE, …) to attempt to raise it. The default limit may be as 
low as 256, depending on OS version and on how the process is launched. (Note 
that each two-way network connection uses two file descriptors.) setrlimit() 
should be able to raise the file descriptor limit to a few thousand unless your 
system administrator is mean.

If you hit that limit you should see errors from various network API. File a 
bug report if you find some API that causing weird crashes instead of failing 
gracefully or halting with an appropriate error message when you run out of 
file descriptors.


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

Re: NSCalendar and NSDates prior to October 15, 1582

2015-02-05 Thread Greg Parker

 On 2015 Jan 30, at 12:32, Steve Mykytyn wrote:
 
 The documentation for the Date and Time Programming Guide for iOS does not 
 seem to be telling the truth, or perhaps I'm doing something wrong.

Please file a bug report.

 On Feb 5, 2015, at 6:56 AM, Jeffrey Oleander jgo...@yahoo.com wrote:
 
 Some countries did not adopt the Gregorian adjustment until the 1750s, and 
 others much later than that (Russia partially converted in 1700 but not 
 completely until 1922, Turkey in 1926).  Anyway, it's not something you can 
 do a neat mathematical conversion on and have it work perfectly everywhere 
 and for every date.   What of those of us who have to deal with dates going 
 back to e.g. 1200BCE?

The Date and Time Programming Guide mentions that issue too.

Some countries adopted the Gregorian calendar at various later times. 
Nevertheless, for consistency the change is modeled at the same time regardless 
of locale. If you need absolute historical accuracy for a particular locale…


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