Re: Design pattern for bulk data handling

2014-02-08 Thread Tito Ciuro
Also, consider dropping the table indexes before you start inserting. After the 
you're done inserting, rebuild the indexes. This should give you an an 
additional performance boost.

For even more speed, consider turning off the following setting:

http://www.sqlite.org/pragma.html#pragma_synchronous

*warning*: read the link carefully and understand what it does before using it!

-- Tito


 On Feb 8, 2014, at 14:25, Jens Alfke j...@mooseyard.com wrote:
 
 
 On Feb 8, 2014, at 10:20 AM, Ben ben_cocoa_dev_l...@yahoo.co.uk wrote:
 
 This is fine for most things, except that I sometimes need faster access to 
 the underlying database - for example, when importing/exporting data. In 
 these cases I'm after bulk data throughput without the overhead of 
 creating/destroying many NSOperations with completion handlers since there 
 can be in the order of millions of statements to handle.
 
 You can read arbitrarily large amounts of data with a single statement, so 
 that's not an issue. But in general it takes many statements to insert a lot 
 of rows. (And for performance reasons you really want to group all of those 
 statements in a single transaction, or you'll lose an order of magnitude of 
 performance.)
 
 What I'd do is provide a new operation type that does a bulk-insert or 
 bulk-update. When run the operation performs a series of SQL statements 
 starting with a BEGIN and ending with an END.
 
 —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/tciuro%40mac.com
 
 This email sent to tci...@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: Fast hash of NSData?

2013-11-29 Thread Tito Ciuro
Hello,

If memory serves well, CRC-32 is quite fast. How large are the BLOBs you're 
trying to compare? If they're not too large, the following may work for you:

#include zlib.h

@implementation NSData (CRC32)
- (uint32_t)CRC32
{
uLong crc = crc32(0L, NULL, 0);
crc = crc32(crc, [self bytes], [self length]);
return crc;
}
@end

--Tito

On Nov 29, 2013, at 12:36 PM, Kyle Sluder k...@ksluder.com wrote:

 On Nov 29, 2013, at 11:58 AM, Graham Cox graham@bigpond.com wrote:
 
 
 Another general question.
 
 Does anyone have a quick-and-dirty (but functional) way to hash NSData? I’m 
 currently using SHA-1 but it’s quite slow. All I need is a way to determine 
 whether one block of data is identical to another or not - but every bit 
 counts.
 
 Just for the sake of the list, though I'm certain you're aware of this 
 yourself: you can't use a hash function to check for equality unless it is a 
 perfect hash function. You can use it to reduce the number of comparisons per 
 candidate, but you'll always wind up doing at least O(M+N) comparisons (where 
 M is the size of your input and N is the length of your hash output).
 
 Often, it's better to improve the data structure before trying a different 
 hash function. It's much easier to reason about how to improve a solution in 
 terms of algorithm analysis of your data structure rather than it is to 
 perform an empirical analysis of a specific hash function's 
 collision-to-speed tradeoffs.
 
 Long way of saying: what's the actual problem you're trying to solve? Maybe a 
 hash table is a poor fit.
 
 --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/tciuro%40mac.com
 
 This email sent to tci...@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: 30x faster JSON date parsing

2013-09-09 Thread Tito Ciuro
What's premature about it?

-- Tito


 On Sep 9, 2013, at 10:14 AM, Marcel Weiher marcel.wei...@gmail.com wrote:
 
 Hi Jens,
 
 Premature optimization is the root of all evil!
 
 Er, I misspelled:  “very cool, nice job!”
 
 On Sep 9, 2013, at 18:11 , Jens Alfke j...@mooseyard.com wrote:
 
 [..] 
 [fg160,160,160;16:34:40.488| [fg0,128,0;[;NSDateFormatter took  26.97 
 µsec
 [fg160,160,160;16:34:48.649| [fg0,128,0;[;CBLParseDatetook   0.47 
 µsec (58x)
 
 Now, the tradeoff is that the optimized code parses only ISO 8601 dates — 
 this is the informal standard used with JSON, so it’s become really common. 
 It looks like “2013-09-09T17:52:12Z”.
 
 That might actually be a feature.  (Also:  didn’t know ISO did informal 
 standards…)
 
 
 [1] 
 http://vombat.tumblr.com/post/60530544401/date-parsing-performance-on-ios-nsdateformatter-vs
 [2] 
 https://github.com/couchbase/couchbase-lite-ios/blob/master/Source/CBLParseDate.c
 
 Marcel
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/tciuro%40mac.com
 
 This email sent to tci...@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: How to determine the Http Method type being implemented for web service API

2013-06-24 Thread Tito Ciuro
Let's not forget about PATCH:

http://tools.ietf.org/html/rfc5789

I'm not sure if it's been ratified already, but it could be around the corner. 
It's already part of technologies like Node.js, for example.

-- Tito


On Jun 24, 2013, at 11:14, Jens Alfke j...@mooseyard.com wrote:

 
 On Jun 23, 2013, at 11:05 PM, Omkar Ramtekkar 
 omkar_ramtek...@persistent.co.in wrote:
 
 Server side people have implemented a few web services. I need to use those 
 methods, but I'm not sure which http method to use Get or POST”.
 
 If it’s really a RESTful API, then you use GET to retrieve the contents of a 
 resource, and POST to create a new resource (without specifying a URL for it.)
 
 In general, anything that has side effects (i.e. changing the state of the 
 data on the server) cannot be a GET request. And PUT requests only create new 
 resources (at the given URL), and DELETE only deletes resources. So anything 
 that doesn’t fall into those categories is going to be a POST.
 
 If I use GET as http method and if the server web service is being 
 implemented in POST then I get 404 or similar http error code.
 Is there any way to find out the http method type being implemented for a 
 web server API?
 
 Read the documentation of the service, or ask an expert for help. Seriously. 
 HTTP is not self-documenting this way. The answer about looking at the 405 
 response is correct as far as it goes, and there’s also the OPTIONS method, 
 but both of those will only tell you what methods are allowed on that URL, 
 not what they *mean*.
 
 If you try to implement a client for a web API by guesswork, your code is 
 likely to be fragile and break in the future if any changes are made on the 
 server side. Unless you’re trying to reverse-engineer a proprietary API, you 
 should really really follow the documentation.
 
 —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/tciuro%40mac.com
 
 This email sent to tci...@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

Crash when calling va_arg()

2012-07-04 Thread Tito Ciuro
Hello,

I've hit a wall while experimenting with variadic functions and blocks. The 
code works pretty well until the second block is executed. After that, it 
crashes the next time va_arg() gets called. Here's the code:

#import Foundation/Foundation.h

typedef id (^fooBlock)(id result, NSError **error);
void blockStep(fooBlock firstBlock, ...);

int main(int argc, const char * argv[])
{
@autoreleasepool {

blockStep (
   ^ (id result, NSError **error) {
   NSMutableString *value = [NSMutableString new];
   [value appendString:@One!];
   return value;
   },
   ^ (id result, NSError **error) {
   NSMutableString *value = [NSMutableString new];
   if (nil != result) {
   [value appendString:result];
   [value appendString:@, ];
   }
   [value appendString:@Two!];
   return value;
   }
);

}
return 0;
}

#pragma mark -

void blockStep(fooBlock firstBlock, ...)
{
va_list args;
va_start(args, firstBlock);
id result = nil;

do {
result = firstBlock(result, nil);
NSLog(@%@, result);
} while (nil != (firstBlock = va_arg(args, fooBlock)));

va_end(args);
}

The output looks like this:

 2012-07-04 16:18:40.000 BlockStep[12418:303] One!
 2012-07-04 16:18:56.533 BlockStep[12418:303] One!, Two!

I've eliminated the crash by adding a nil sentinel in blockStep():

blockStep (
   ^ (id result, NSError **error) {
   NSMutableString *value = [NSMutableString new];
   [value appendString:@One!];
   return value;
   },
   ^ (id result, NSError **error) {
   NSMutableString *value = [NSMutableString new];
   if (nil != result) {
   [value appendString:result];
   [value appendString:@, ];
   }
   [value appendString:@Two!];
   return value;
   },
   nil
);

This allows it to work without crashing, but I'd like if possible to avoid 
having to place the sentinel. Any ideas?

Thanks in advance,

-- Tito
___

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: Crash when calling va_arg()

2012-07-04 Thread Tito Ciuro
Hi Fritz and Jens,

It makes total sense now. Out of the two options (NULL sentinel vs a number to 
indicate the number of args), I would choose NULL because out of the two, it's 
more foolproof. Is there a consensus about which option is considered best 
practice?

Thanks again,

-- Tito

On Jul 4, 2012, at 4:43 PM, Fritz Anderson fri...@manoverboard.org wrote:

 On 4 Jul 2012, at 6:30 PM, Tito Ciuro wrote:
 
 void blockStep(fooBlock firstBlock, ...)
 {
   va_list args;
   va_start(args, firstBlock);
   id result = nil;
 
   do {
   result = firstBlock(result, nil);
   NSLog(@%@, result);
   } while (nil != (firstBlock = va_arg(args, fooBlock)));
 
   va_end(args);
 }
 
 The output looks like this:
 
 2012-07-04 16:18:40.000 BlockStep[12418:303] One!
 2012-07-04 16:18:56.533 BlockStep[12418:303] One!, Two!
 
 I've eliminated the crash by adding a nil sentinel in blockStep():
 
   blockStep (
  ^ (id result, NSError **error) {
  NSMutableString *value = [NSMutableString new];
  [value appendString:@One!];
  return value;
  },
  ^ (id result, NSError **error) {
  NSMutableString *value = [NSMutableString new];
  if (nil != result) {
  [value appendString:result];
  [value appendString:@, ];
  }
  [value appendString:@Two!];
  return value;
  },
  nil
   );
 
 
 This allows it to work without crashing, but I'd like if possible to avoid 
 having to place the sentinel. Any ideas?
 
 Not possible.
 
 Notionally, all parameters are passed to C functions in memory on a stack, 
 which is unformatted and could contain anything. A function has no way of 
 knowing how many parameters have been pushed onto the stack, or where the 
 memory trails off into saved processor state and the like, or the types, or 
 the amounts of memory they subtend….
 
 Most variadic functions require sentinels (usually NULL) to tell them to stop 
 looking for parameters. The best-known exceptions are printf()-family 
 functions, which know what to find on the stack because the format string 
 tells them.
 
   — F
 
 -- 
 Fritz Anderson
 Xcode 4 Unleashed: Don't bring your bathroom copy into the kitchen — were you 
 raised in a barn?
 http://x4u.manoverboard.org/
 
 
 


___

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

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

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

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

Re: Crash when calling va_arg()

2012-07-04 Thread Tito Ciuro
I think it's easier to place a NULL than having to keep track of the number of 
args. None of them is foolproof, but placing NULL is all it takes to make it 
work. One could plug the wrong number of args and boum! Forcing to keep the 
number in sync is an extra step.

-- Tito

On Jul 4, 2012, at 5:40 PM, Charles Srstka cocoa...@charlessoft.com wrote:

 On Jul 4, 2012, at 7:34 PM, Tito Ciuro wrote:
 
 It makes total sense now. Out of the two options (NULL sentinel vs a number 
 to indicate the number of args), I would choose NULL because out of the two, 
 it's more foolproof. Is there a consensus about which option is considered 
 best practice?
 
 Neither method is much foolproof at all — both of them can easily be 
 undermined by even low-level fools. However, using a NULL sentinel is what is 
 more commonly done.
 
 Charles
 

___

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

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

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

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

Exiting cleanly the init method under ARC

2012-06-27 Thread Tito Ciuro
Hello,

Under non-ARC, an init method may be implemented like this:

- (id)init
{
self = [super init];

if (self) {
if (somecondition != good) {
[self release];
return nil;
}

// Initialize ivars here as usual...
}

return self;
}

However, if something critical happens within the init method when ARC is 
activated, what would be the proper way to exit? Would it look like this?:

- (id)init
{
self = [super init];

if (self) {
if (somecondition != good) {
// Cleanup here if needed...
return nil;
}
}

return self;
}

Thanks,

-- Tito


___

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: Exiting cleanly the init method under ARC

2012-06-27 Thread Tito Ciuro
Thanks Quincey!

On Jun 27, 2012, at 9:54 AM, Quincey Morris wrote:

 On Jun 27, 2012, at 09:12 , Tito Ciuro wrote:
 
 However, if something critical happens within the init method when ARC is 
 activated, what would be the proper way to exit? Would it look like this?:
 
 - (id)init
 {
self = [super init];
 
if (self) {
if (somecondition != good) {
// Cleanup here if needed...
return nil;
}
}
 
return self;
 }
 
 Yes, just return nil.
 
 Like other local variables, 'self' will be released automatically (if 
 non-nil) at exit from its scope, which is the entire method in this case. 
 Because this is an 'init'-family method, the return value is retained (if 
 non-nil) on execution of the 'return' statement.
 
 If you put those 2 behaviors together, you'll see that your ARC code has the 
 same memory management effect as your non-ARC code, no matter which 'return' 
 statement is executed.
 
 

___

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 Instruments to profile UITableView drawing

2012-04-26 Thread Tito Ciuro
Hello,

I would also profile it with the Core Animation instrument. Make sure you 
select the Color Blended Layers checkbox in the Debug Options area. This will 
apply a colored overlay to each view (green is opaque and red is transparent.)

-- Tito

On Apr 26, 2012, at 11:59 AM, Mikkel Islay wrote:

 
 On 26 Apr 2012, at 20:37, Marco Tabini wrote:
 
 I wonder if someone could point me to the right way to profile 
 poorly-performing custom-drawn UITableView cells. I've come across this 
 problem several times, and usually manage to figure out how to solve it, but 
 my process is not very scientific—there's far too much trial and error 
 involved, and I wonder whether there isn't a known way to pinpoint exactly 
 which part of the code causes a table to stutter using Instruments. I've 
 tried Googling for the problem, but it seems to me that the vast majority of 
 people giving suggestions are focusing on known techniques to make table 
 cells perform, rather than trying to understand where an already-implemented 
 table is going astray.
 
 If you haven't done it already, the first thing to try is running  your app 
 through the Time Profiler.
 
 Mikkel
 
 
 ___
 
 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/tciuro%40mac.com
 
 This email sent to tci...@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: NSObject hierarchy browser. Is there such a thing?

2012-04-02 Thread Tito Ciuro
Hello,

FYI… CocoaNav doesn't seem to be working on Mac OS X Lion 10.7.3 (crashes in 
RBApplicationMain)

-- Tito

On Apr 2, 2012, at 6:04 PM, jonat...@mugginsoft.com wrote:

 http://inexdo.com/CocoaNav

___

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: List of registered URI handlers?

2011-10-12 Thread Tito Ciuro
Thanks Ken. I appreciate it.

Regards,

-- Tito

On Oct 11, 2011, at 8:06 PM, Ken Thomases wrote:

 On Oct 11, 2011, at 5:18 PM, Tito Ciuro wrote:
 
 How would I determine which URI handlers are registered with the system? For 
 example, amzn://, fb://, etc.
 
 Is there a way to determine this type of information?
 
 Not programmatically, I don't believe.  (Launch Services will show you the 
 URI handler for a given scheme, but won't list the known schemes.)
 
 You can extract that information from the output of
 
 /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister
  -dump
 
 However, you probably can't rely on the format of that output being stable 
 from release to release.  I think that's considered a diagnostic tool, not a 
 supported interface.
 
 Cheers,
 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


List of registered URI handlers?

2011-10-11 Thread Tito Ciuro
Hello,

How would I determine which URI handlers are registered with the system? For 
example, amzn://, fb://, etc.

Is there a way to determine this type of information?

Thanks,

-- Tito
___

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: Receiving Crash Reports

2011-09-28 Thread Tito Ciuro
I would also consider plcrashreporter (iPhone and Mac OS X):

http://code.google.com/p/plcrashreporter/

-- Tito

On Sep 28, 2011, at 5:07 PM, koko wrote:

 When a user of my app experiences a crash (arrggh) I would like intercept the 
 Apple provided crash report window with the 'Send to Apple button so I can 
 have it sent to me.
 
 Is there a way to do this?
 
 -koko___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/tciuro%40mac.com
 
 This email sent to tci...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Launching an app with extended rights

2011-09-18 Thread Tito Ciuro
Hello,

When my app launches, I'd like it to listen to port 80 or 443. To do that, I 
believe I need to use Security Framework Authorization API to obtain extended 
rights. A potential solution is to split the app's executable int two parts:

1) one executable, the main one that first gets launched, obtains extended 
rights.
2) the app itself, which is the embedded web server.

When the user double clicks the app, it would execute (1) with:

SFAuthorization *authorization = [SFAuthorization authorization];
BOOL result = [authorization obtainWithRights:NULL
flags:kAuthorizationFlagExtendRights
  environment:NULL
 authorizedRights:NULL
error:error];

and then use NSTask to launch (2) via:

+ (NSString *)stringByLaunchingPath:(NSString *)processPath
withArguments:(NSArray *)arguments
authorization:(SFAuthorization *)authorization
error:(NSError **)error;

Is this approach the way to go, or is there an easier/better/safer way do to 
that?

Thank you,

-- Tito
___

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


[SOLVED] Re: Launching an app with extended rights

2011-09-18 Thread Tito Ciuro
Hi Nick,

Thank so much for the heads up. Works fine!

Thanks for the help,

-- Tito

On Sep 18, 2011, at 10:13 AM, Nick Zitzmann wrote:

 
 On Sep 18, 2011, at 10:05 AM, Tito Ciuro wrote:
 
 Hello,
 
 When my app launches, I'd like it to listen to port 80 or 443. To do that, I 
 believe I need to use Security Framework Authorization API to obtain 
 extended rights. A potential solution is to split the app's executable int 
 two parts:
 
 1) one executable, the main one that first gets launched, obtains extended 
 rights.
 2) the app itself, which is the embedded web server.
 
 When the user double clicks the app, it would execute (1) with:
 
   SFAuthorization *authorization = [SFAuthorization authorization];
   BOOL result = [authorization obtainWithRights:NULL
   
 flags:kAuthorizationFlagExtendRights
 environment:NULL
authorizedRights:NULL
   error:error];
 
 You need to obtain the system.privilege.admin right if you want to launch a 
 task with root privileges. You should also use the 
 kAuthorizationFlagInteractionAllowed and kAuthorizationFlagPreAuthorize flags 
 as well.
 
 and then use NSTask to launch (2) via:
 
 + (NSString *)stringByLaunchingPath:(NSString *)processPath
  withArguments:(NSArray *)arguments
  authorization:(SFAuthorization *)authorization
  error:(NSError **)error;
 
 Is this approach the way to go, or is there an easier/better/safer way do to 
 that?
 
 You must use AuthorizationExecuteWithPrivileges() to launch a task with 
 privileges; you cannot do that with NSTask.
 
 Nick Zitzmann
 http://www.chronosnet.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: Launching an app with extended rights

2011-09-18 Thread Tito Ciuro
Hi Kyle,

This is exactly what I've done, except that I'm not using SMJobBless.

-- Tito

On Sep 18, 2011, at 2:08 PM, Kyle Sluder wrote:

 The modern way to do this is to split the server portion into a separate 
 process and use SMJobBless to submit it as a privileged launchd task.
 
 --Kyle Sluder
 (Sent from the road)
 
 On Sep 18, 2011, at 9:05 AM, Tito Ciuro tci...@mac.com wrote:
 
 Hello,
 
 When my app launches, I'd like it to listen to port 80 or 443. To do that, I 
 believe I need to use Security Framework Authorization API to obtain 
 extended rights. A potential solution is to split the app's executable int 
 two parts:
 
 1) one executable, the main one that first gets launched, obtains extended 
 rights.
 2) the app itself, which is the embedded web server.
 
 When the user double clicks the app, it would execute (1) with:
 
   SFAuthorization *authorization = [SFAuthorization authorization];
   BOOL result = [authorization obtainWithRights:NULL
   
 flags:kAuthorizationFlagExtendRights
 environment:NULL
authorizedRights:NULL
   error:error];
 
 and then use NSTask to launch (2) via:
 
 + (NSString *)stringByLaunchingPath:(NSString *)processPath
   withArguments:(NSArray *)arguments
   authorization:(SFAuthorization *)authorization
   error:(NSError **)error;
 
 Is this approach the way to go, or is there an easier/better/safer way do to 
 that?
 
 Thank you,
 
 -- Tito
 ___
 
 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/kyle.sluder%40gmail.com
 
 This email sent to kyle.slu...@gmail.com

___

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

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

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

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


Re: Launching an app with extended rights

2011-09-18 Thread Tito Ciuro
I just downloaded SMJobBless. Thanks for the info Kyle.

Regards,

-- Tito

On Sep 18, 2011, at 4:25 PM, Kyle Sluder wrote:

 The modern way is to use SMJobBless. ;-)
 
 Apple is discouraging people from using AuthorizationExecuteWithPrivileges 
 directly. Your scenario sounds like the perfect use case for launchd.
 
 --Kyle Sluder
 (Sent from the road)
 
 On Sep 18, 2011, at 2:27 PM, Tito Ciuro tci...@mac.com wrote:
 
 Hi Kyle,
 
 This is exactly what I've done, except that I'm not using SMJobBless.
 
 -- Tito
 
 On Sep 18, 2011, at 2:08 PM, Kyle Sluder wrote:
 
 The modern way to do this is to split the server portion into a separate 
 process and use SMJobBless to submit it as a privileged launchd task.
 
 --Kyle Sluder
 (Sent from the road)
 
 On Sep 18, 2011, at 9:05 AM, Tito Ciuro tci...@mac.com wrote:
 
 Hello,
 
 When my app launches, I'd like it to listen to port 80 or 443. To do that, 
 I believe I need to use Security Framework Authorization API to obtain 
 extended rights. A potential solution is to split the app's executable int 
 two parts:
 
 1) one executable, the main one that first gets launched, obtains extended 
 rights.
 2) the app itself, which is the embedded web server.
 
 When the user double clicks the app, it would execute (1) with:
 
 SFAuthorization *authorization = [SFAuthorization authorization];
 BOOL result = [authorization obtainWithRights:NULL
 
 flags:kAuthorizationFlagExtendRights
   environment:NULL
  authorizedRights:NULL
 error:error];
 
 and then use NSTask to launch (2) via:
 
 + (NSString *)stringByLaunchingPath:(NSString *)processPath
 withArguments:(NSArray *)arguments
 authorization:(SFAuthorization *)authorization
 error:(NSError **)error;
 
 Is this approach the way to go, or is there an easier/better/safer way do 
 to that?
 
 Thank you,
 
 -- Tito
 ___
 
 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/kyle.sluder%40gmail.com
 
 This email sent to kyle.slu...@gmail.com
 

___

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

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

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

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


Is it possible to traverse dictionaries and arrays using KVC?

2011-08-16 Thread Tito Ciuro
Hello,

In KVC, the setValue:forKeyPath: method is super handy to set values in deep 
hierarchies. I was wondering if it would be possible to access array elements 
using KVC. I haven't seen any reference about it in the docs, so I was 
wondering if it's at all possible. Example:

NSDictionary (characters)
 |-- NSDictionary (friends)
|-- NSMutableArray (jim, sarah, peter)

Using a key path such as characters.friends.usa[2] (or something similar), 
could I access peter?

Traversing it manually isn't a problem, but if KVC can do it for me, then great!

Thanks,

-- Tito
___

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: Is it possible to traverse dictionaries and arrays using KVC?

2011-08-16 Thread Tito Ciuro
Hm. I missed that thread. Thanks Jens!

-- Tito

On Aug 16, 2011, at 12:52 PM, Jens Alfke wrote:

 
 On Aug 16, 2011, at 11:03 AM, Tito Ciuro wrote:
 
 In KVC, the setValue:forKeyPath: method is super handy to set values in deep 
 hierarchies. I was wondering if it would be possible to access array 
 elements using KVC.
 
 I asked this a couple of weeks ago and was told the answer is “no”. 
 Apparently because implementing KV observing of such key paths would be too 
 difficult.
 
 —Jens
 

___

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

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

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

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


Re: Creating a TCP server?

2011-07-26 Thread Tito Ciuro
Hello,

More options:

A simple, extensible HTTP server in Cocoa
http://cocoawithlove.com/2009/07/simple-extensible-http-server-in-cocoa.html

How to Write a Cocoa Web Server
http://macdevcenter.com/pub/a/mac/2006/11/14/how-to-write-a-cocoa-web-server.html

A Simple HTTP Server
http://culturedcode.com/cocoa/

-- Tito

On Jul 26, 2011, at 5:38 PM, davel...@mac.com wrote:

 Here's some sample code (I'm not the author)
 
 https://bitbucket.org/snej/mynetwork/overview
 
 Dave
 
 
 On Jul 26, 2011, at 4:00 PM, Bing Li wrote:
 
 Hi, Rick,
 
 If you are familiar with BSD socket, you can program with it to create a TCP
 server. I have done that successfully.
 
 Thanks,
 Bing
 
 On Wed, Jul 27, 2011 at 3:17 AM, Rick Mann rm...@latencyzero.com wrote:
 
 Hi. I need to build a little serial port-to-TCP server (so that clients can
 connect to my Mac to interact with a serial port). Among other things, I
 want to advertise this using Bonjour.
 
 How do I create a TCP server in Cocoa? It seems like CF networking is my
 best bet, but I thought TCP should be easy via Cocoa. I briefly looked at
 NSSocket and NSStream, but they're not really what I want, I think.
 
 And to verify: is NSNetServices what I need to publish the Bonjour name?
 
 Thanks.
 
 --
 Rick
 ___
 
 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/tciuro%40mac.com
 
 This email sent to tci...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: EXC_BAD_ACCESS in NSApplicationMain

2011-07-24 Thread Tito Ciuro
Hi Joseph,

If you type 'bt' in GDB, do you see something like this by any chance?:

 #74 0x7fff8686f312 in -[NSIBObjectData initWithCoder:] ()
 #75 0x7fff827fbe73 in _decodeObjectBinary ()
 #76 0x7fff827fb2ed in _decodeObject ()
 #77 0x7fff8686ea41 in loadNib ()
 #78 0x7fff8686dfa1 in +[NSBundle(NSNibLoading) 
 _loadNibFile:nameTable:withZone:ownerBundle:] ()
 #79 0x7fff8686ddd9 in +[NSBundle(NSNibLoading) loadNibNamed:owner:] ()
 #80 0x7fff8686b35b in NSApplicationMain ()
 #81 0x000100011370 in main (argc=1, argv=0x7fff5fbff5c0) at main.m:13
 (gdb)

I started seeing this in Xcode 4.1 and 4.2 too.

-- Tito

On Jul 24, 2011, at 7:50 PM, Ayers, Joseph wrote:

 In XCode 4.1. and Lion,, compiling for OS X 10.6, My application is crashing 
 in main.m. Specifically it exhibits EXC_BAD_ACCESS errors in main.m, 
 NSApplicationMain and obj_msgSend on disassembly. I've got symbolic 
 breakpoints at:  “objc_exception_throw” and “[NSException raise]“.
 
 Any idea how to get beyond this?
 
 Thanks,
 Joseph
 
 main.m
 
 #import Cocoa/Cocoa.h
 
 int main(int argc, char *argv[])
 {
return NSApplicationMain(argc, (const char **) argv);Thread 1 
 EXC_BAD_ACCESS (code = 1, address = 0x553838b0)
 }
 
 Errors
 
 in  objc_msgSend_disassembly_0x97876d54.s
 
 The offending line is
 
 0x97876d54:  movl   8(%edi,%edx,4), %eax  Thread 1 EXC_BAD_ACCESS (code = 1,
 
 in NSApplicationMain_disassembly_0x94cd58f3.s
 
 The offending line is:
 
 0x94cd58f3:  testb  %al, %al  Thread 1 EXC_BAD_ACCESS (code = 1,
 
 in main.m, the offending line is:
 
return NSApplicationMain(argc, (const char **) argv);  Thread 1 
 EXC_BAD_ACCESS (code = 1,
 
 argc = (int) 1
 argv = (char**) 0xbb18
 
 
 
 Joseph Ayers, Professor
 Department of Biology and
 Marine Science Center
 Northeastern University
 East Point, Nahant, MA 01908
 Phone (781) 581-7370 x309(office), x335(lab)
 Boston: 444 Richards Hall (617) 373-4044
 Cellular (617) 755-7523, FAX: (781) 581-6076
 Google Voice: (781) 346-9589
 eMail: lobs...@neu.edumailto:lobs...@neu.edu
 iPhone: robopl...@gmail.commailto:robopl...@gmail.com
 http://www.neurotechnology.neu.edu/
 http://robobees.seas.harvard.edu/
 http://cyberplasm.net/
 
 
 
 
 
 
 
 
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/tciuro%40mac.com
 
 This email sent to tci...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Core Data dog-slow when using first time after boot

2011-07-22 Thread Tito Ciuro
Hello all,

I saw an interesting reply from Dr. Hipp posted today:

http://www.mail-archive.com/sqlite-users@sqlite.org/msg62618.html

This seems to explain why SQLite (and Core Data) might sometimes launch and 
execute very slowly.

-- Tito

On Sep 3, 2009, at 5:00 PM, Ben Trumbull wrote:

 
 On Sep 3, 2009, at 4:49 AM, Ruotger Skupin wrote:
 
 Since it's not a many to many, you can perform the prefetching 
 effectively by hand using a fetch request to preload the relevant 
 destination rows with an IN query based on the data you initially fetched 
 for the source entity.  You shouldn't have to, but if you've run into a 
 bug, that's how you could workaround it.
 
 You still haven't described the NSPredicate you were using with 
 filteredArrayUsingPredicate.  Being more forthcoming about the context 
 and details of your problem will help us get you answers more quickly.
 This is the predicate I was using for the test of the original post, but 
 since I use Smart Folders predicates can look a lot different (i.e.: 
 complex):
 
 (additionalInfo.onTheFlyIsInternal == 0 AND additionalInfo.isSuppressed != 
 1) AND (account.uniqueID IN {D1AB3788-00DF-4475-A979-CE3EFC3987B5} OR 
 FALSEPREDICATE)
 
 
 
 You'll want to prefetch additionalInfo and account.
 
 Hm. Problem here is: As mentioned I use the predicate for a smart group. So 
 the predicate can vary wildly and can reference basically any entity in the 
 model. So what is the best strategy here? Decompile the predicate (which 
 is built by an NSPredicateEditor) and prefetch the keypaths it takes? 
 Prefetch everything?
 
 
 Prefetching everything is usually undesirable.  The easiest approximate 
 solution is to just track the hot button relationships for each of your core 
 entities, and look up which keypaths to prefetch by entity name.  Of course, 
 you can also do a lot less filtering in memory if you pass the predicates to 
 the database with the fetch request.  You only need to prefetch relationships 
 you are going to use in memory.  You don't need to prefetch anything that's 
 simply used as part of the predicate in the fetch request itself.
 
 Walking through the predicate and gathering up the keypaths used is very 
 tedious, but not especially difficult, if you find yourself wanting a 
 complete solution.
 
 - Ben
 
 ___
 
 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/tciuro%40mac.com
 
 This email sent to tci...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Method willPerformClientRedirectToURL: delay: fireDate: forFrame: not being called

2011-07-05 Thread Tito Ciuro
Hello,

I have a question regarding WebKit. The redirect sent by the server works fine 
(gets displayed properly) but the following method is never invoked:

- (void)webView:(WebView *)sender willPerformClientRedirectToURL:(NSURL *)URL 
delay:(NSTimeInterval)seconds fireDate:(NSDate *)date forFrame:(WebFrame *)frame

Instead, the following two methods get invoked:

- (void)webView:(WebView *)sender 
didReceiveServerRedirectForProvisionalLoadForFrame:(WebFrame *)frame
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame

I would like to log the URL being redirected to, but 
willPerformClientRedirectToURL is never called. Any idea why?

Thanks,

-- Tito
___

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: Method willPerformClientRedirectToURL: delay: fireDate: forFrame: not being called

2011-07-05 Thread Tito Ciuro
Hello again,

Partially solved:

- (void)webView:(WebView *)sender 
didReceiveServerRedirectForProvisionalLoadForFrame:(WebFrame *)frame
{
NSLog(@didReceiveServerRedirectForProvisionalLoadForFrame detected: %@, 
sender);
NSLog(@%@,frame provisionalDataSource]request]URL]absoluteString]);
}

I can now obtain the redirected URL, but I'm still wondering why 
willPerformClientRedirectToURL is not being called...

-- Tito

On Jul 5, 2011, at 5:42 PM, Tito Ciuro wrote:

 Hello,
 
 I have a question regarding WebKit. The redirect sent by the server works 
 fine (gets displayed properly) but the following method is never invoked:
 
 - (void)webView:(WebView *)sender willPerformClientRedirectToURL:(NSURL *)URL 
 delay:(NSTimeInterval)seconds fireDate:(NSDate *)date forFrame:(WebFrame 
 *)frame
 
 Instead, the following two methods get invoked:
 
 - (void)webView:(WebView *)sender 
 didReceiveServerRedirectForProvisionalLoadForFrame:(WebFrame *)frame
 - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
 
 I would like to log the URL being redirected to, but 
 willPerformClientRedirectToURL is never called. Any idea why?
 
 Thanks,
 
 -- Tito
___

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

2011-06-26 Thread Tito Ciuro
Hello,

If you have access to the Developer Forums, check the very first entry in Core 
OS named Five Reasons Why Synchronous Networking Is Bad, by Apple's Quinn 
The Eskimo!:

https://devforums.apple.com/thread/9606?tstart=0

Cheers,

-- Tito

On Jun 26, 2011, at 9:51 PM, Jerry Krinock wrote:

 
 On 2011 Jun 26, at 09:52, Fritz Anderson wrote:
 
 Synchronous network operations are almost always a bad idea. …, …, …, …,
 
 and the error object that you get from 
 -sendSynchronousRequest:returningResponse:error: if it fails is quite 
 nondescript.
 
 ___
 
 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/tciuro%40mac.com
 
 This email sent to tci...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Memory Management for an Array

2011-06-12 Thread Tito Ciuro
Hi Bing,

Looks good. One comment though: I would return nil instead of an empty string 
to differentiate an actual value (the empty string) vs. nothing was read.

-- Tito

On Jun 12, 2011, at 11:29 AM, Bing Li wrote:

 Dear all,
 
 Do you think the below method is a correct solution to manage memory? I am
 not sure if the array, nodes, could leak?
 
 Thanks so much!
 
 Best regards,
 Bing
 
 + (NSString *)read:(NSString *)xml Path:(NSString *)xPath
 {
NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithXMLString:xml
 options:NSXMLDocumentTidyXML error:NULL];
NSArray *nodes = [xmlDoc nodesForXPath:xPath error:NULL];
[xmlDoc release];
if ([nodes count]  0)
{
return [[nodes objectAtIndex:0] stringValue];
}
else
{
return @;
}
 }
 ___
 
 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/tciuro%40mac.com
 
 This email sent to tci...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


NSOpenPanel not honoring some settings

2011-05-31 Thread Tito Ciuro
Hello,

I'm trying to display an NSOpenPanel that only allows to select plist files. I 
have the following code in place:

 NSOpenPanel *openPanel= [NSOpenPanel openPanel];
 
 [openPanel setResolvesAliases:YES];
 [openPanel setCanChooseDirectories:NO];
 [openPanel setAllowsMultipleSelection:NO];
 [openPanel setCanChooseFiles:YES];
 [openPanel setPrompt:@Open];
 [openPanel setAllowedFileTypes:[NSArray arrayWithObject:@plist]];
 [openPanel beginSheetForDirectory:NSHomeDirectory() file:nil 
 modalForWindow:window modalDelegate:self 
 didEndSelector:@selector(didEndImportSheet:returnCode:contextInfo:) 
 contextInfo:NULL];


The documentation about setAllowedFileTypes states that The file type can be a 
common file extension, or a UTI... so I have no idea why the plist extension 
is not being honored. To make things more interesting, I can select directories 
(even though I have set setCanChooseDirectories with NO).

Any idea why it's not working? What am I missing?

Thanks!

-- Tito

___

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: NSOpenPanel not honoring some settings

2011-05-31 Thread Tito Ciuro
Hi Quincey,

On May 31, 2011, at 9:35 PM, Quincey Morris wrote:

 On May 31, 2011, at 21:00, Tito Ciuro wrote:
 
   [openPanel setAllowedFileTypes:[NSArray arrayWithObject:@plist]];
   [openPanel beginSheetForDirectory:NSHomeDirectory() file:nil 
 modalForWindow:window modalDelegate:self 
 didEndSelector:@selector(didEndImportSheet:returnCode:contextInfo:) 
 contextInfo:NULL];
 
 You're using the wrong methods for NSOpenPanel. These methods are for 
 NSSavePanel, prior to 10.6.
 
 For 10.5 compatibility, use the deprecated 
 'beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:'
  method and specify the file type array as a parameter.
 
 Or for 10.6 only, use 'beginSheetModalForWindow:completionHandler:' in 
 combination with 'setAllowedFileTypes:'.
 
 Also see here:
 
   
 http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSSavePanel_Class/Reference/Reference.html
 
 under the 'setAllowedFileTypes:' method description, for a note about 
 NSOpenPanel.

I don't know how I missed this...

I wish Xcode 4 had warned me that 
'beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:'
 has been deprecated in 10.6. That would have saved some trouble!

Thanks a lot for the help,

-- Tito
___

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


Cocoa Asynchronous API Design

2011-05-24 Thread Tito Ciuro
Hello,

I have a question about Cocoa API design. I think I can give a concrete example 
to best explain what the goal is. Assume I have an Inventory service and I need 
to write a client API that deals with it. Goals:

- The API should allow me to add, update, delete and search items
- These operations should be asynchronous

Path #1:
Public method: - (void)addInventoryItem:(MyInventoryItem *)inventoryItem;
Implement a protocol for each of the actions (i.e. add, update, delete and 
search. See URLConnection, Connection Completion section) Example:
 - Delegate method if successful: - 
(void)itemAdditionDidSucceed:(MyInventoryItem *)accountInfo;
 - Delegate method if failure: - (void)itemAddition:(MyInventoryItem 
*)accountInfo didFailWithError:(NSError *)error;
Pros: the delegate method can receive specific data objects specific to the 
operation (i.e. MyInventoryItem for addInventoryItem vs NSArray for 
searchInventory)
Cons: the protocol could end up being verbose, with many delegates to be 
implemented (i.e. success/failure for add, update, delete and search... 8 
methods in total)

Path #2:
Implement a protocol with two methods: success and failure (see URLConnection, 
Connection Completion section)
Implement an action class that encapsulates the action (i.e. add, update, 
delete and search) and the actual data needed for the operation
Public method: - (void)addInventoryItem:(MyInventoryAction *)inventoryAction;
 Delegate method if successful: - (void)actionDidSucceed:(MyInventoryAction 
*) inventoryAction;
 Delegate method if failure: - (void)action:(MyInventoryAction *) 
inventoryAction didFailWithError:(NSError *)error;
Pros: simplifies the number of delegate methods
Cons: when the delegate method gets called, we have to introspect to obtain the 
action and associated data. Also, the data could be a single inventory item 
(i.e. add, update, delete) or an array of them (i.e. search), so we would have 
to cast the return type (id since it's generic) to its proper class based on 
the type of action.

Which option do you feel is better? Would you consider a different solution? I 
really don't mind if the implementation is more complex if that makes the life 
of the developer easier. Perhaps Path #2 is better because it would simplify 
the Client code, but I would like to hear what other developers think.

Thanks in advance,

-- Tito
___

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

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

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

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


Re: Cocoa Asynchronous API Design

2011-05-24 Thread Tito Ciuro
Hi Seth,

I thought about adding blocks, but I would like to support older iPhones if 
possible. Blocks were introduced in iOS 4, correct?

Thanks,

-- Tito

On May 24, 2011, at 10:30 AM, Seth Willits wrote:

 On May 24, 2011, at 8:25 AM, Tito Ciuro wrote:
 
 I have a question about Cocoa API design. I think I can give a concrete 
 example to best explain what the goal is. Assume I have an Inventory service 
 and I need to write a client API that deals with it. Goals:
 
 - The API should allow me to add, update, delete and search items
 - These operations should be asynchronous
 
 
 - (void)addInventoryItem:(Item *)item resultHandler:(void (^)(NSError * 
 error))resultHandler;
 
 In this way, the result handling block already has access to every parameter 
 and the receiver, so there's no need for verbose delegate methods which pass 
 them all back, or packing and and unpacking an object which contains them all.
 
 
 --
 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Visually disabling some checkboxes in a NSTableView

2011-05-21 Thread Tito Ciuro
Hello,

I have a table view which contains a column that displays checkboxes. I would 
like to disable and gray out some of the checkboxes, so I guess there are two 
possible ways (perhaps there's another way?):

1) disable the control (i.e. gray out) so that the user cannot toggle it (in 
one single method)
2) ignore tracking for the affected rows and disable the cell/control (in two 
or more methods)

I've tried option #2. I've implemented - 
(BOOL)tableView:shouldTrackCell:forTableColumn:row: and the click gets properly 
ignored. However, I'd also like to indicate to the user that the checkbox 
cannot be toggled, and this is where I'm stuck. How would some of these 
checkboxes be grayed out?

Thanks in advance,

-- Tito
___

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: Visually disabling some checkboxes in a NSTableView

2011-05-21 Thread Tito Ciuro
Hi Kyle,

The method -tableView:willDisplayCell:forTableColumn:row: did the trick, thanks!

-- Tito

On May 21, 2011, at 10:02 AM, Kyle Sluder wrote:

 On Sat, May 21, 2011 at 9:19 AM, Tito Ciuro tci...@mac.com wrote:
 Hello,
 
 I have a table view which contains a column that displays checkboxes. I 
 would like to disable and gray out some of the checkboxes, so I guess there 
 are two possible ways (perhaps there's another way?):
 
 1) disable the control (i.e. gray out) so that the user cannot toggle it (in 
 one single method)
 
 There is no checkbox control. The tableview uses one checkbox cell to
 draw the entire column. So you can't just selectively disable checkbox
 instances because there is only one checkbox.
 
 Disable the cell in -tableView:willDisplayCell:forTableColumn:row:.
 Alternatively, if you're using bindings, bind the table column's
 enabled binding to a key that returns YES or NO as appropriate.
 
 --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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: prevent multiple instances of a program

2011-05-11 Thread Tito Ciuro
Hi Martin,

One way to do it is via flock():

http://developer.apple.com/library/mac/#documentation/darwin/reference/manpages/man2/flock.2.html

-- Tito

On May 11, 2011, at 6:04 PM, Dave DeLong wrote:

 There are a bunch of ways to do this, but the general principle is that when 
 an instance of the app starts, it makes its presence known somehow (touching 
 a file, broadcasting a distributed notification, vending a distributed 
 object, etc).  Then when a second instance starts, it tries to find a 
 previous instance (looking for the file, broadcasting a distributed 
 notification and waiting for a response, connecting to a distributed object, 
 etc).  If it finds one, it kills itself.
 
 Dave
 
 On May 11, 2011, at 2:02 PM, Martin Batholdy wrote:
 
 Hi,
 
 My program consists of a menu item and is NSUIagent - so it is hidden in the 
 Mac OS app-bar.
 
 Now what surprises me is that I am able to open several instances of this 
 program.
 Every time I click on the app-file a new symbol appears and I have a new 
 instance of my program running.
 
 How can I prevent this?
 (so that system-wide you can only have one instance of the program running)
 
 Is there a build-option in xCode for this?
 
 
 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:
 http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com
 
 This email sent to davedel...@me.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/tciuro%40mac.com
 
 This email sent to tci...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


[ANN] NanoStore 2.0 is now available

2011-05-09 Thread Tito Ciuro
Hello everyone,

Last year I announced NanoStore, a SQLite-based engine to store and retrieve 
dictionaries while fully indexing its contents. NanoStore made some people 
happy, but I quickly realized that it could be better as feedback poured in. 
While NanoStore was simple and fairly efficient, the API could be improved with 
new features. Most important of all, I had to keep it simple. Today I'm happy 
to announce version 2.0, which brings several additions including:

* Storing your own custom objects
* Bags, a free-form relational system
* Dynamic queries
* Expressions and predicates
* Fully documented API

I have written a detailed introduction with more information, examples and 
performance tips. More information can be found below:

Project and Intro page: https://github.com/tciuro/NanoStore
API documentation: 
http://dl.dropbox.com/u/2601212/NanoStore%202.0/html/index.html
NanoStore on Twitter: http://twitter.com/nanostoredev

Why did I write NanoStore? Because I felt that Core Data, while extremely 
powerful, was too complicated to master. Many developers do not want (nor care) 
about database design. A common feature developers wanted was to store data 
organically, that is, as the application evolves without having to revisit the 
schema and having to migrate it time after time. I believe that NanoStore sits 
nicely between SQLite and Core Data. So if you feel that Core Data or SQLite is 
a bit heavy for you, take NanoStore for a spin!

Cheers,

-- Tito
___

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 can I make a window just like the Anxiety App?

2011-02-20 Thread Tito Ciuro
Take a look at this too. Lots of goodies:

http://brandonwalkin.com/bwtoolkit/

-- Tito

On Feb 20, 2011, at 2:51 AM, 23Labs wrote:

 You can see the screenshot
 herehttp://www.anxietyapp.com/popups/list-window.html
 .
 Anxiety app has a window title which can be clicked and then popups a menu
 list.
 I can't find any clue in IB. There seems no way we can customize the window
 title bar in IB.
 So how can I achieve this?
 
 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:
 http://lists.apple.com/mailman/options/cocoa-dev/tciuro%40mac.com
 
 This email sent to tci...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Performing the selector from a stored IMP

2011-02-11 Thread Tito Ciuro
Hello,

Being curious about the performance implications of using NSInvocation vs 
Objective-C message send vs IMP-cached message send, I was surprised to see how 
much slower NSInvocation seems to be compared to the other two mechanisms (the 
following data was last collected on Leopard, so these results could have 
changed in SnowLeopard):

NameIterations  Total time (sec) Time per (ns)
IMP-cached message send 10  0.7 
  0.7



Objective-C message send10  4.9   4.9



NSInvocation message send   10000.8   77.3

The above metrics can be found here: 
http://www.mikeash.com/pyblog/performance-comparisons-of-common-operations-leopard-edition.html

Cheers,

-- Tito

On Feb 11, 2011, at 12:20 PM, Joanna Carter wrote:

 Hi Matt
 
 Consider NSInvocation... m.
 
 Hmmm, nice!
 
 My only objection to using it in the circumstances I have is that it is a lot 
 more code to setup than the idea of a protocol with three methods, 
 implemented by the target class.
 
 However, I am indebted to you for pointing out this class and shall remember 
 it for future use. IMO, this is truly the next best thing to a delegate (as 
 it is known in C#).
 
 Joanna
 
 --
 Joanna Carter
 Carter Consulting
 
 ___
 
 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/tciuro%40mac.com
 
 This email sent to tci...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Determining whether a dictionary is mutable or not

2011-01-15 Thread Tito Ciuro
Hi Ken,

On Jan 15, 2011, at 7:36 AM, Ken Ferry wrote:

 I'm not sure this has been made clear:  It is intentional that it is 
 difficult to determine whether a dictionary is mutable.  
 
 That's because you shouldn't do it.  Whether a dictionary is mutable _to_you_ 
 is a matter of what's in the header for the method you obtained it from.
 
 Suppose that some object keeps a mutable array as its internal state.  It 
 also has an accessor that lets you look at the array as an immutable array.  
 If you introspect it and realize its mutable, is it safe to mutate?  No!  
 It's part of the object's internal state, you cannot just mess with it.  
 
 It is unsafe in general to introspect mutability.
 
 -Ken
 Cocoa Frameworks

It makes sense what you're saying because introspecting an object bypassing its 
accessors would break encapsulation. From the client's perspective this is very 
clear: use the methods provided and don't mess with the internals. Roger that.

However, how about the other way around? Say you have the same class you 
mentioned. Internally, it has a mutable array which one can manipulate via 
dedicated accessors. This object has an init method which accepts an array as 
input. The client is (should?) be free to pass an immutable or mutable array 
with values. I see at least two ways to honor this input and initialize the 
object:

1) add the input objects to the internal array (i.e. - 
(void)addObjectsFromArray:(NSArray *)otherArray)
2) assign the mutable version of the input array to the internal array (i.e. 
internalArray = [theInputArray mutableCopy])

In case of #2, (perhaps mistakenly) I was attempting to check whether it was 
necessary to mutate an already mutable array. It just seemed like the right 
thing to do: figure out whether the input array is mutable, if it isn't then 
make it mutable. Then proceed to set the array as the object's contents. 
However, since this init process is called once, perhaps it just makes sense to 
always call mutableCopy and be done regardless of the input type. Would this be 
the right approach perhaps?

My main concern is how to deal with this mutability/non-mutability from the 
inside, not the outside.

Thanks for the help,

-- Tito
___

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: Determining whether a dictionary is mutable or not

2011-01-15 Thread Tito Ciuro
On Jan 15, 2011, at 1:04 PM, Ken Thomases wrote:

 On Jan 15, 2011, at 5:38 AM, Tito Ciuro wrote:
 
 On Jan 15, 2011, at 7:36 AM, Ken Ferry wrote:
 
 I'm not sure this has been made clear:  It is intentional that it is 
 difficult to determine whether a dictionary is mutable.  
 
 That's because you shouldn't do it.  Whether a dictionary is mutable 
 _to_you_ is a matter of what's in the header for the method you obtained it 
 from.
 
 Suppose that some object keeps a mutable array as its internal state.  It 
 also has an accessor that lets you look at the array as an immutable array. 
  If you introspect it and realize its mutable, is it safe to mutate?  No!  
 It's part of the object's internal state, you cannot just mess with it.  
 
 It is unsafe in general to introspect mutability.
 
 -Ken
 Cocoa Frameworks
 
 It makes sense what you're saying because introspecting an object bypassing 
 its accessors would break encapsulation. From the client's perspective this 
 is very clear: use the methods provided and don't mess with the internals. 
 Roger that.
 
 However, how about the other way around? Say you have the same class you 
 mentioned. Internally, it has a mutable array which one can manipulate via 
 dedicated accessors. This object has an init method which accepts an array 
 as input. The client is (should?) be free to pass an immutable or mutable 
 array with values. I see at least two ways to honor this input and 
 initialize the object:
 
 1) add the input objects to the internal array (i.e. - 
 (void)addObjectsFromArray:(NSArray *)otherArray)
 2) assign the mutable version of the input array to the internal array (i.e. 
 internalArray = [theInputArray mutableCopy])
 
 In case of #2, (perhaps mistakenly) I was attempting to check whether it was 
 necessary to mutate an already mutable array. It just seemed like the right 
 thing to do: figure out whether the input array is mutable, if it isn't then 
 make it mutable. Then proceed to set the array as the object's contents. 
 However, since this init process is called once, perhaps it just makes sense 
 to always call mutableCopy and be done regardless of the input type. Would 
 this be the right approach perhaps?
 
 My main concern is how to deal with this mutability/non-mutability from the 
 inside, not the outside.
 
 You should copy any state which you need to be private.
 
 What if the code which calls your init method had, in fact, passed a mutable 
 array?  Why in the world would you want to make that your internal state?  
 That would mean that your internal state is open to manipulation from the 
 outside.  The caller could, after the new object is initialized, modify its 
 (the caller's) mutable array.  They have thus unwittingly modified the 
 internal state of the new object.
 
 And, again, if you had declared your initializer to take an immutable object 
 as its parameter, why would you imagine that the caller would be OK with you 
 mutating it?
 
 Sharing state is always fraught with difficulties.  When it comes to value 
 objects, including collections, you should default to making copies.  Only 
 retain them (and thus share state with the provider) after careful 
 consideration of the close coupling that would result.  And even then, it 
 makes little sense to have the behavior be conditional on the object's 
 mutability.
 
 I'll also point out that code which tries to determine the mutability and 
 then takes one of two different paths is more complex and error-prone than 
 code which just does one straightforward thing.
 
 Regards,
 Ken

Ken, looks like I wasn't clear enough. In general (not only in this case) I 
would not retain the array unless it was immutable. Otherwise, as you well 
point out, retaining a mutable one  would allow external clients manipulate the 
array bypassing the accessors provided, thus breaking encapsulation.

I understand that my original approach was flawed because I really don't need 
(nor should I care) about the original state of the collection being passed: 
since the class allows the data to be manipulated via accessors, the inited 
data, if provided, should be copied internally regardless of the array state 
being passed. That would make a private copy of the data only accessible via 
the class accessors.

I was looking for a solution where there was not a problem.

Best regards,

-- Tito
___

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


Determining whether a dictionary is mutable or not

2011-01-14 Thread Tito Ciuro
Hello,

Trying to determine whether an NSDictionary is mutable or not fails with these 
two tests:

// Variable info could be NSDictionary or NSMutableDictionary. Assume it's an 
NSDictionary.

BOOL isKindOfClass = [info isKindOfClass:[NSMutableDictionary class]];
BOOL respondsToSelector = [info 
respondsToSelector:@selector(setObject:forKey:)];

After executing the above statements, both variables 'isKindOfClass' 
and'respondsToSelector' are set to YES.

When I obtain the class type of 'info', I get:

(gdb) po [info class]
NSCFDictionary

The question is: if 'info' is an immutable dictionary, why is isKindOfClass and 
respondsToSelector telling me that it is mutable?

Thanks,

-- Tito
___

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: Determining whether a dictionary is mutable or not

2011-01-14 Thread Tito Ciuro
Hi Mike,

Given that the caller can pass a NSDictionary or an NSMutableDictionary, I 
wanted to test its mutability before calling setObject:forKey:. In order to 
avoid calling mutableCopy each time, I thought it would be more efficient to 
test it and then call mutableCopy only when needed.

Thanks for the help,

-- Tito

On Jan 14, 2011, at 12:15 PM, Mike Abdullah wrote:

 If you want to test if a dictionary is immutable, you are almost certainly 
 doing it wrong. When passed a dictionary in to a method either:
 
 A) Make a mutable copy if that's what you need
 B) -copy it if you want it to be immutable. (This is not inefficient as it 
 sounds because immutable objects implement -copy to do a -retain and return 
 self instead)
 
 On 14 Jan 2011, at 10:48, Tito Ciuro wrote:
 
 Hello,
 
 Trying to determine whether an NSDictionary is mutable or not fails with 
 these two tests:
 
 // Variable info could be NSDictionary or NSMutableDictionary. Assume it's 
 an NSDictionary.
 
 BOOL isKindOfClass = [info isKindOfClass:[NSMutableDictionary class]];
 BOOL respondsToSelector = [info 
 respondsToSelector:@selector(setObject:forKey:)];
 
 After executing the above statements, both variables 'isKindOfClass' 
 and'respondsToSelector' are set to YES.
 
 When I obtain the class type of 'info', I get:
 
 (gdb) po [info class]
 NSCFDictionary
 
 The question is: if 'info' is an immutable dictionary, why is isKindOfClass 
 and respondsToSelector telling me that it is mutable?
 
 Thanks,
 
 -- Tito
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.net
 

___

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

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

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

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


Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Tito Ciuro
Hi Jonathan,

On Jan 14, 2011, at 12:34 PM, jonat...@mugginsoft.com wrote:

 On 14 Jan 2011, at 11:25, Tito Ciuro wrote:
 
 Hi Mike,
 
 Given that the caller can pass a NSDictionary or an NSMutableDictionary, I 
 wanted to test its mutability before calling setObject:forKey:. In order to 
 avoid calling mutableCopy each time, I thought it would be more efficient to 
 test it and then call mutableCopy only when needed.
 
 Thanks for the help,
 
 -- Tito
 
 
 
 
 In this case just check if your object responds to setObject:forKey:
 If it does its mutable, if not it isn't.

But that's the problem: it always returns YES, even when it's an immutable 
dictionary.

-- Tito
___

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: Determining whether a dictionary is mutable or not

2011-01-14 Thread Tito Ciuro
Hi Pablo,

On Jan 14, 2011, at 1:35 PM, Pablo Pons Bordes wrote:

 Hello,
 
 To determine if a dictionary is mutable or Inmutable you just need to use the 
 isKindOfClass method, instead of use respondsToSelector.
 
 I did a test to reproduce your problem and couldn't reproduce your problem, 
 so my conclusion is that actually you are receiving a mutable Dictionary when 
 you think is unMutable 

Hm. No, I'm not getting a mutable dictionary because I'm seeing a log message 
complaining that I'm trying to call setObject:forKey: on an immutable object.

Thanks!

-- Tito
___

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: Determining whether a dictionary is mutable or not

2011-01-14 Thread Tito Ciuro
Thanks a lot everyone for the great feedback. I really appreciate it! :-)

Cheers,

-- Tito

On Jan 14, 2011, at 6:39 PM, Corbin Dunn wrote:

 
 On Jan 14, 2011, at 4:44 AM, Tito Ciuro wrote:
 
 Hi Pablo,
 
 On Jan 14, 2011, at 1:35 PM, Pablo Pons Bordes wrote:
 
 Hello,
 
 To determine if a dictionary is mutable or Inmutable you just need to use 
 the isKindOfClass method, instead of use respondsToSelector.
 
 I did a test to reproduce your problem and couldn't reproduce your problem, 
 so my conclusion is that actually you are receiving a mutable Dictionary 
 when you think is unMutable 
 
 Hm. No, I'm not getting a mutable dictionary because I'm seeing a log 
 message complaining that I'm trying to call setObject:forKey: on an 
 immutable object.
 
 I think you should work backwards on this one...break on NSLog and go from 
 there
 
 Something's mutating an dictionary that shouldn't be mutated.
 
 corbin
 
 

___

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


Analyzing a Framework

2010-11-30 Thread Tito Ciuro
Hello,

I have been writing a Framework which is tested by a few unit tests. While I 
try to exercise the API as much as possible, I know for sure I'm not covering 
everything. I also don't have a good idea where the performance bottlenecks 
are. Therefore, I'd like to do two things: run gcov and Shark.

Questions:

1) How would I run gcov on a framework? Could I gather the stats between start 
and finish when running the unit tests?
2) How can I analyze the performance bottlenecks with Shark? Could I also do 
that when running the unit tests?

I imagine that if I was certain each call was tested properly and I could 
sample each of the tests, then I would have a pretty good idea where the issues 
are lingering. I've read Apple's docs on the subject, but there is little or 
nothing said about frameworks.

Any ideas or pointers?

Thanks in advance,

-- Tito
___

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


What is the expected Cocoa API behavior in an incomplete object traversal?

2010-10-15 Thread Tito Ciuro
Hello,

I'm implementing a method and I'm not sure what the behavior should be when 
detecting an anomaly.

Case in point: I have a method that iterates through an array of objects. As I 
traverse the array, I'm, checking whether the object in the array conforms to a 
custom protocol. If it does, everything is fine and I process it. However, if 
at some point I detect that the array contains a non-conforming object, what 
should the method do?:

a) skip the non-conforming object and continue processing and return a BOOL or 
fill an NSError?
b) stop processing and return a BOOL or fill an NSError?
c) throw an exception?

Since the method would end up processing less objects that the developer 
intended, I wonder what Cocoa developers would expect in this case...

Thanks,

-- Tito
___

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: What is the expected Cocoa API behavior in an incomplete object traversal?

2010-10-15 Thread Tito Ciuro
Hi Corbin,

On 15/10/2010, at 16:55, Corbin Dunn wrote:

  If it is instead some array input that the user provided, and it is a user 
 error to provide the wrong input, then you should return a user-presentable 
 NSError and the caller should present the error on failure.

This sounds right to me.

Well, in a normal situation the array would contain conforming objects. 
However, as it can happen once in a while, one can add an object to an array 
thinking it's of one type when in fact it's another. Currently, the method 
detects this anomaly and skips it while continuing traversing the array. It 
then fills an NSError (as long as the user cares) and returns NO. This is the 
method I'm talking about:

- (BOOL)addObjectsFromArray:(NSArray *)someObjects error:(out NSError 
**)outError;

I wonder if returning a BOOL and filling out an NSError is a bit too much 
though...

Thanks to everyone who have responded,

-- Tito
___

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: What is the expected Cocoa API behavior in an incomplete object traversal?

2010-10-15 Thread Tito Ciuro
Hi Martin,

On 15/10/2010, at 20:48, Martin Wierschin wrote:

 Well, in a normal situation the array would contain conforming objects. 
 However, as it can happen once in a while, one can add an object to an array 
 thinking it's of one type when in fact it's another.
 
 When you say one can add, do you mean that the user chooses these objects 
 in the GUI somehow? If so, I might recommend you disallow the user from 
 making such an errant choice in the first place. Think of the Open panel: the 
 application controls which files are selectable. Or maybe if the user chooses 
 objects of the wrong class, the operation should be disabled in the GUI. Or 
 do preflight checks that present an explanation sheet allowing the user to 
 cancel or just skip the non-conforming objects. Your description so far is 
 too vague to know what's best, but presenting an NSError after the operation 
 completes doesn't sound like the best solution.
 
 If you really mean that occasionally your code adds an object to an array 
 thinking it's another class, that sounds like a bug to me and I'd throw an 
 exception so you can fix it ASAP. Though in a non-debug build I might choose 
 to gracefully just skip the object and avoid the exception, as you're doing 
 now.
 
 ~Martin

No, the method is part of an API meant for developers. So even though in most 
cases there won't be an issue, occasionally there could be some anomaly, in 
which non-conforming objects could slip through. How to let the developer know 
that this issue happened is what I'm interested in.

Thanks for the help,

-- Tito
___

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


Why is 'missing sentinel in function call' appearing?

2010-10-14 Thread Tito Ciuro
Hello,

I'm seeing a weird behavior in Xcode 3.2.4/GCC 4,2. The warning I'm getting is: 
missing sentinel in function call

This is how I have defined the methods:

+ (NSFSomeClass*)someClassWithObjects:(NSArray *)someObjects
{
return [[[self alloc]initWithObjects:someObjects]autorelease];  
warning occurs here
}

- (id)initWithObjects:(NSArray *)someObjects
{
if (self = [self init]) {
...
}

return self;
}

However, if I change the class method to the following, the warning disappears:

+ (NSFSomeClass*)someClassWithObjects:(NSArray *)someObjects
{
return [[[self alloc]initWithObjects:someObjects, nil]autorelease];
}

Any idea why this is happening? Why does it require a sentinel when I'm passing 
an array? Another observation:

GCC 4.0 = no warning
GCC 4.2 = warning
LLVM GCC 4.2 = warning
LLVM compiler 1.5 = no warning

Is this a GCC 4.2/LLVM GCC4.2 bug?

And while we're at it... since the library I'm writing works on both Mac OS X 
and iOS, which compiler is recommended?

Thanks,

-- Tito
___

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: Why is 'missing sentinel in function call' appearing?

2010-10-14 Thread Tito Ciuro
Hi David,

On 14/10/2010, at 17:32, David Duncan wrote:

 On Oct 14, 2010, at 1:30 PM, David Duncan wrote:
 
 On Oct 14, 2010, at 1:25 PM, Tito Ciuro wrote:
 
  return [[[self alloc]initWithObjects:someObjects]autorelease]; 
  warning occurs here
 
 
 -initWithObjects expects a list with a nil terminator, which you have not 
 provided. If this works it is because you are getting very lucky with what 
 is already on the stack.
 
 
 Sorry, read a bit too fast. The problem is likely that [self alloc] returns 
 'id' so the compiler doesn't know which -initWithObjects: you mean, so it 
 arbitrarily picks the NSArray version, which then flags the error. You could 
 not be seeing this on other compilers due to the arbitrary part, but 
 overall you should probably name your -initWithObjects: method something else.
 --
 David Duncan

Cool! I have changed the method name.

Thanks for the help!

-- Tito
___

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: Why is 'missing sentinel in function call' appearing?

2010-10-14 Thread Tito Ciuro
Hi Greg,

On 14/10/2010, at 17:50, Greg Parker wrote:

 There's already a method -[NSArray initWithObjects:], but it accepts a 
 nil-terminated list of objects. The compiler warns if you call [array 
 initWithObjects:a, b, c] and forget the nil terminator.
 
 `[self alloc]` returns `id`, so the compiler has to guess which method 
 prototype to use, yours or NSArray's. If it guesses wrong, you'll get that 
 warning. Sometimes you'll get crashes or incorrect parameter values when the 
 compiler guesses wrong, but in this case the generated code happens to work 
 correctly.
 
 I'd recommend changing your method name. -initWithArray: would work, matching 
 -[NSArray initWithArray:(NSArray*)array]. 
 
 The other workaround is to cast the result of +alloc: [(NSFSomeClass*)[self 
 alloc] initWithObjects:someObjects]. But that's fragile if you forget 
 somewhere.
 
 
 Another observation:
 
 GCC 4.0 = no warning
 GCC 4.2 = warning
 LLVM GCC 4.2 = warning
 LLVM compiler 1.5 = no warning
 
 Is this a GCC 4.2/LLVM GCC4.2 bug?
 
 No. gcc-4.0 simply does not implement the sentinel warning for Objective-C 
 methods. If gcc-4.0 guesses wrong, there's no warning and the code happens to 
 run correctly.
 
 
 And while we're at it... since the library I'm writing works on both Mac OS 
 X and iOS, which compiler is recommended?
 
 I'd recommend llvm-gcc on all current platforms and architectures.
 
 
 -- 
 Greg Parker gpar...@apple.com Runtime Wrangler

Done. Thanks again for the help,

-- Tito
___

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


NanoStore has moved to Google Code

2010-10-06 Thread Tito Ciuro
Hello everyone,

Based on feedback from other developers, I have decided to move NanoStore, a 
Cocoa wrapper for SQLite, to Google Code:

http://code.google.com/p/nanostore/

The Sourceforge repository is now considered obsolete and will be removed 
shortly.

Regards,

-- Tito
___

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: [ANN] Release: NanoStore 1.0 for Mac and iOS

2010-09-23 Thread Tito Ciuro
Hi Thomas,

On 23/09/2010, at 02:15, Thomas Davie wrote:

 
 On 23 Sep 2010, at 03:51, Tito Ciuro wrote:
 
 Today, Webbo is pleased to announce the release of NanoStore:
 
 http://sourceforge.net/projects/nanostore/
 
 NanoStore is a Cocoa wrapper for SQLite, a C library that implements an 
 embeddable SQL database engine.
 
 With NanoStore, you store data using a dictionary of any depth. The 
 developer can decide what to store on the fly, unlike other systems that 
 require the developer to design a schema. With NanoStore just build your 
 dictionary and store it. That's all there is to it! Every data element in 
 the dictionary is indexed (except BLOBs) so there's no need to keep a list 
 of indexed separately. You can disable indexing, import your data in batch 
 mode, save it and then reindex at once, which is quite efficient. For even 
 better performance, all I/O can be performed in memory and save the new 
 database to disk at once, which is even faster. And if you feel adventurous, 
 you can even do that in Fast mode and save extra SQLite processing.
 
 Sounds like fun!  Can you explain some of the differences between using this 
 or using CoreData to achieve a similar thing?

Hm. That would be discussed better on a White Paper or similar. There are 
countless tutorials and documents about Core Data already. What I can do 
however is to provide a small example to illustrate how NanoStore works.

I believe (please correct me if I'm wrong) that Core Data stores the data 
atomically for both, XML and binary formats. That, if I'm not mistaken requires 
the datafile to be read in memory. Not so with NanoStore: the SQLite database 
is the storage system and the API stores and retrieves dictionaries. Another 
strong point is that you can store whatever you want: from the developer's 
perspective, there is no schema, so objects of different weight or complexity 
can be stored with ease and retrieved back verbatim.

Now... I like Core Data. I really do. But some times I get the feeling that 
it's too heavy for simple tasks. Plus, making CD work requires some reading, 
while NanoStore requires a fraction of the time to get it working. I believe 
that many developers will welcome this addition, as they will be able to 
concentrate their effort on other parts of their app. In essence, I designed 
NanoStore to be simple, relatively powerful and fast, while demanding a minimum 
effort from the developer. Time will tell if I'm wrong :-)

Regards,

-- Tito
___

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: [ANN] Release: NanoStore 1.0 for Mac and iOS

2010-09-23 Thread Tito Ciuro
Hi Thomas,

On 23/09/2010, at 04:19, Thomas Davie wrote:

 
 On 23 Sep 2010, at 07:39, Tito Ciuro wrote:
 
 Hm. That would be discussed better on a White Paper or similar. There are 
 countless tutorials and documents about Core Data already. What I can do 
 however is to provide a small example to illustrate how NanoStore works.
 
 I believe (please correct me if I'm wrong) that Core Data stores the data 
 atomically for both, XML and binary formats. That, if I'm not mistaken 
 requires the datafile to be read in memory.
 
 That's incorrect, CoreData gives you the choice of XML, binary or SQLite 
 backends.  When using the SQLite one it reads the data lazily.

I was thinking about the XML option (binary as well) and didn't finish the 
sentence, leaving SQLite behind. Yes, Core Data offers three backends.

Thanks for the correction,

-- Tito

___

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: [ANN] Release: NanoStore 1.0 for Mac and iOS

2010-09-23 Thread Tito Ciuro
Hi Chris,

On 23/09/2010, at 04:27, Chris Hanson wrote:

 On Sep 22, 2010, at 11:39 PM, Tito Ciuro wrote:
 
 I believe (please correct me if I'm wrong) that Core Data stores the data 
 atomically for both, XML and binary formats. That, if I'm not mistaken 
 requires the datafile to be read in memory. Not so with NanoStore:
 
 Not really so with Core Data either.
 
 Core Data has the concept of both atomic and non-atomic persistent stores.
 
 Core Data’s binary and XML persistent stores are atomic, so they are read and 
 written like documents (all at once).  Developers can also create your own 
 kinds of atomic persistent stores by subclassing NSAtomicStore.  (Also, the 
 XML persistent store is not available on iOS, only on Mac OS X.)
 
 Core Data’s SQLite persistent store is quite explicitly not atomic: It uses 
 transactions against SQLite.  The entire persistent store does not need to be 
 read into memory, only the data requested; the entire persistent store is not 
 written upon a save, only the data changed.
 
  -- Chris

As I mentioned to Thomas, I left part of the sentence out, so thanks for 
clarifying this. What I meant was precisely what you have written so eloquently.

NanoStore is also explicitly not atomic: It uses transactions against SQLite as 
well storing and indexing the dictionaries.

Thanks Chris,

-- Tito___

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


[ANN] Release: NanoStore 1.0 for Mac and iOS

2010-09-22 Thread Tito Ciuro
NanoStore 1.0
© Webbo, L.L.C., 2010. All rights reserved.
September 21, 2010

Today, Webbo is pleased to announce the release of NanoStore:

http://sourceforge.net/projects/nanostore/

NanoStore is a Cocoa wrapper for SQLite, a C library that implements an 
embeddable SQL database engine.

With NanoStore, you store data using a dictionary of any depth. The developer 
can decide what to store on the fly, unlike other systems that require the 
developer to design a schema. With NanoStore just build your dictionary and 
store it. That's all there is to it! Every data element in the dictionary is 
indexed (except BLOBs) so there's no need to keep a list of indexed separately. 
You can disable indexing, import your data in batch mode, save it and then 
reindex at once, which is quite efficient. For even better performance, all I/O 
can be performed in memory and save the new database to disk at once, which is 
even faster. And if you feel adventurous, you can even do that in Fast mode and 
save extra SQLite processing.

All these variations come with pros and cons, sure... but you have a choice. 
You can decide what's best *for you* and map a strategy to *your* model as 
there accessors available for most SQLite settings and pragmas that will allow 
you to tune it to your liking.

The list of classes include:

NSFNanoStore
NSFNanoExpression
NSFNanoSearch
NSFNanoResult

You also have full access to the sqlite3* handle, in case you need it (hey... 
you're a developer right?)

In addition, the NanoStore project includes:

- Unit tests
- An iOS plain-vanilla app to demonstrate how easy it is to embed NanoStore in 
your project

Enjoy!

-- Tito

*
Tito Ciuro
RD Group, Webbo, L.L.C.

___

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


TARGET_OS_MAC section generates a compile error on an iPhone project?

2010-08-27 Thread Tito Ciuro
Hello,

I have code that's part of a framework and I'd like to port it to iOS. I tried 
isolating the code like so:

//
//  RootViewController.m
//  iPhoneTest

#import RootViewController.h

@implementation RootViewController


#pragma mark -
#pragma mark View lifecycle

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}

- (NSUInteger)systemPageSize
{
static NSUInteger __sSystemPageSize = NSNotFound;

#if TARGET_OS_MAC
if (NSNotFound == __sSystemPageSize) {
NSTask *task = [[NSTask alloc] init];

// do something here...

[task release];
}
#elif TARGET_OS_IPHONE

// do something here...

#endif

return __sSystemPageSize;
}

When I compile the standard iPhone boilerplate app from Xcode I get the 
following error:

 /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m: In function 
 '-[RootViewController systemPageSize]':
 /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m:23: error: 
 'NSTask' undeclared (first use in this function)
 /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m:23: error: 
 (Each undeclared identifier is reported only once
 /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m:23: error: for 
 each function it appears in.)
 /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m:23: error: 
 'task' undeclared (first use in this function)
 {standard input}:59:non-relocatable subtraction expression, 
 L_OBJC_SELECTOR_REFERENCES_0 minus L001$pb
 {standard input}:59:symbol: L_OBJC_SELECTOR_REFERENCES_0 can't be undefined 
 in a subtraction expression
 {standard input}:54:non-relocatable subtraction expression, 
 L_OBJC_CLASSLIST_SUP_REFS_$_0 minus L001$pb
 {standard input}:54:symbol: L_OBJC_CLASSLIST_SUP_REFS_$_0 can't be 
 undefined in a subtraction expression
 {standard input}:unknown:Undefined local symbol L_OBJC_CLASSLIST_SUP_REFS_$_0
 {standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_0


I know NSTask doesn't exist on iOS, so I was hoping to implement the method 
that would work for both Mac and iOS by specifying TARGET_OS_MAC and 
TARGET_OS_IPHONE. What am I missing?

Thanks,

-- Tito
___

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: TARGET_OS_MAC section generates a compile error on an iPhone project?

2010-08-27 Thread Tito Ciuro
Excellent!

Thanks Kyle!

-- Tito

On 27/08/2010, at 14:02, Kyle Sluder wrote:

 Read this: 
 http://sealiesoftware.com/blog/archive/2010/8/16/TargetConditionalsh.html
 
 --Kyle Sluder
 (Sent from the road)
 
 On Aug 27, 2010, at 1:47 PM, Tito Ciuro tci...@mac.com wrote:
 
 Hello,
 
 I have code that's part of a framework and I'd like to port it to iOS. I 
 tried isolating the code like so:
 
 //
 //  RootViewController.m
 //  iPhoneTest
 
 #import RootViewController.h
 
 @implementation RootViewController
 
 
 #pragma mark -
 #pragma mark View lifecycle
 
 - (void)viewWillAppear:(BOOL)animated {
   [super viewWillAppear:animated];
 }
 
 - (NSUInteger)systemPageSize
 {
   static NSUInteger __sSystemPageSize = NSNotFound;
 
 #if TARGET_OS_MAC
   if (NSNotFound == __sSystemPageSize) {
   NSTask *task = [[NSTask alloc] init];
 
   // do something here...
 
   [task release];
   }
 #elif TARGET_OS_IPHONE
 
   // do something here...
 
 #endif
 
   return __sSystemPageSize;
 }
 
 When I compile the standard iPhone boilerplate app from Xcode I get the 
 following error:
 
 /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m: In function 
 '-[RootViewController systemPageSize]':
 /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m:23: error: 
 'NSTask' undeclared (first use in this function)
 /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m:23: error: 
 (Each undeclared identifier is reported only once
 /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m:23: error: 
 for each function it appears in.)
 /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m:23: error: 
 'task' undeclared (first use in this function)
 {standard input}:59:non-relocatable subtraction expression, 
 L_OBJC_SELECTOR_REFERENCES_0 minus L001$pb
 {standard input}:59:symbol: L_OBJC_SELECTOR_REFERENCES_0 can't be 
 undefined in a subtraction expression
 {standard input}:54:non-relocatable subtraction expression, 
 L_OBJC_CLASSLIST_SUP_REFS_$_0 minus L001$pb
 {standard input}:54:symbol: L_OBJC_CLASSLIST_SUP_REFS_$_0 can't be 
 undefined in a subtraction expression
 {standard input}:unknown:Undefined local symbol 
 L_OBJC_CLASSLIST_SUP_REFS_$_0
 {standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_0
 
 
 I know NSTask doesn't exist on iOS, so I was hoping to implement the method 
 that would work for both Mac and iOS by specifying TARGET_OS_MAC and 
 TARGET_OS_IPHONE. What am I missing?
 
 Thanks,
 
 -- Tito
 ___
 
 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/kyle.sluder%40gmail.com
 
 This email sent to kyle.slu...@gmail.com

___

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

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

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

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


Re: TARGET_OS_MAC section generates a compile error on an iPhone project?

2010-08-27 Thread Tito Ciuro
On 27/08/2010, at 14:05, David Duncan wrote:

 
 On Aug 27, 2010, at 10:47 AM, Tito Ciuro wrote:
 
 - (NSUInteger)systemPageSize
 {
   static NSUInteger __sSystemPageSize = NSNotFound;
 
 #if TARGET_OS_MAC
   if (NSNotFound == __sSystemPageSize) {
   NSTask *task = [[NSTask alloc] init];
 
   // do something here...
 
   [task release];
   }
 #elif TARGET_OS_IPHONE
 
   // do something here...
 
 #endif
 
   return __sSystemPageSize;
 }
 
 
 There is no reason to use NSTask for this on the desktop. Just call 
 getpagesize() on either platform.
 --
 David Duncan

Great to know. I'll update the code right away.

Thanks Duncan,

-- Tito

___

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


Redirect NSLog to stdout?

2010-06-29 Thread Tito Ciuro
Hello,

I have written a small app which gets launched when SuperDuper has finished 
backing up my data. The problem is that since NSLog() writes to stderr, 
SuperDuper treats this as an error. The advice I've been given is to redirect 
NSLog() to stdout. One possible solution I can think of is the following:

void NSLogOut (NSString *someString)
{
 [someString writeToFile: @/dev/stdout atomically: NO];
}

Then I can call it everywhere like so:

NSLogOut(@blah);

I don't really like it, since this forces me to use NSLogOut() everywhere... 
which kinda sucks. Instead, is there a way to configure NSLog() so that it 
redirects to stdout instead of stderr?

Thanks,

-- Tito
___

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: Redirect NSLog to stdout?

2010-06-29 Thread Tito Ciuro
Hello everyone,

Thanks everyone that have responded. There are quite a few interesting options, 
some of which I didn't know. It looks like A.M. suggestion is the most 
interesting in my case, since I can create my own function and #define it as 
NSLog (that is, assuming there are no symbol conflicts!)

Again, thanks for the help,

-- Tito

On 29 Jun 2010, at 18:01, A.M. age...@themactionfaction.com wrote:

 
 On Jun 29, 2010, at 10:09 AM, Tito Ciuro wrote:
 
 Hello,
 
 I have written a small app which gets launched when SuperDuper has finished 
 backing up my data. The problem is that since NSLog() writes to stderr, 
 SuperDuper treats this as an error. The advice I've been given is to 
 redirect NSLog() to stdout. One possible solution I can think of is the 
 following:
 
 void NSLogOut (NSString *someString)
 {
[someString writeToFile: @/dev/stdout atomically: NO];
 }
 
 Create your own logging function and then do 
 
 #define NSLog MyLog
 
 for the relevant sources.
 
 Take a look at variadic macros for more information: 
 http://borkware.com/rants/agentm/mlog/
 
 Cheers,
 M
___

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


Trouble embedding a framework in an application

2010-06-02 Thread Tito Ciuro
Hello,

I'm having some trouble embedding a framework in my app. I've done that 
countless times before in other projects and it worked fine, but for some 
reason, it doesn't work this time around. I don't know what I'm missing and I 
get the feeling I'm running in circles. The app launches (and works) fine if I 
launch it from Xcode. However, if I launch from Finder I see the following in 
Console.app

 6/2/10 11:05:46 AM[0x0-0x192192].com.yourcompany.RichEmailSender[4390]
 dyld: Library not loaded: 
 @executable_path/../Frameworks/EDCommon.framework/Versions/A/EDCommon
 6/2/10 11:05:46 AM[0x0-0x192192].com.yourcompany.RichEmailSender[4390]
   Referenced from: 
 /Users/tciuro/Desktop/Builds/Debug/RichEmailSender.app/Contents/MacOS/RichEmailSender
 6/2/10 11:05:46 AM[0x0-0x192192].com.yourcompany.RichEmailSender[4390]
   Reason: image not found
 6/2/10 11:05:46 AMcom.apple.launchd.peruser.501[143]  
 ([0x0-0x192192].com.yourcompany.RichEmailSender[4390]) Job appears to have 
 crashed: Trace/BPT trap
 6/2/10 11:05:46 AMReportCrash[4393]   Saved crash report for 
 RichEmailSender[4390] version ??? (???) to 
 /Users/tciuro/Library/Logs/DiagnosticReports/RichEmailSender_2010-06-02-110546_TurboMonkey.crash
 6/2/10 11:08:34 AMRichEmailSender[4441]   *** Assertion failure in 
 -[MessageExample createMessage], 
 /Users/tciuro/Desktop/RichEmailSender/MessageExample.m:23
 6/2/10 11:08:34 AMRichEmailSender[4441]   could not load image

The crash referenced above shows:

 Process: RichEmailSender [4390]
 Path:
 /Users/tciuro/Desktop/Builds/Debug/RichEmailSender.app/Contents/MacOS/RichEmailSender
 Identifier:  com.yourcompany.RichEmailSender
 Version: ??? (???)
 Code Type:   X86 (Native)
 Parent Process:  launchd [143]
 
 Date/Time:   2010-06-02 11:05:46.302 +0200
 OS Version:  Mac OS X 10.6.3 (10D573)
 Report Version:  6
 
 Exception Type:  EXC_BREAKPOINT (SIGTRAP)
 Exception Codes: 0x0002, 0x
 Crashed Thread:  0
 
 Dyld Error Message:
   Library not loaded: 
 @executable_path/../Frameworks/EDCommon.framework/Versions/A/EDCommon
   Referenced from: 
 /Users/tciuro/Desktop/Builds/Debug/RichEmailSender.app/Contents/MacOS/RichEmailSender
   Reason: image not found


I have googled for info and I've seen a lot of info (and misinformation as 
well), so I tried the following:

1) Drag the frameworks (EDMEssage + EDCommon) to my Xcode project
2) Added a Copy Files Build Phase to the target
3) Selected Frameworks from the popup and checked Copy only when installing 
(info window of the Copy Files Build Phase)
4) Set the Runpath Search Paths to @loader_path/../Frameworks/

Running otool -l shows the following:

 TurboMonkey:~ tciuro$ otool -L 
 /Users/tciuro/Desktop/Builds/Debug/RichEmailSender.app/Contents/MacOS/RichEmailSender
  
 /Users/tciuro/Desktop/Builds/Debug/RichEmailSender.app/Contents/MacOS/RichEmailSender:
   /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa 
 (compatibility version 1.0.0, current version 15.0.0)
   @executable_path/../Frameworks/EDCommon.framework/Versions/A/EDCommon 
 (compatibility version 34.0.0, current version 34.0.0)
   @executable_path/../Frameworks/EDMessage.framework/Versions/A/EDMessage 
 (compatibility version 17.0.0, current version 17.0.0)
   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
 version 125.0.1)
   /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 
 227.0.0)
   
 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 
 (compatibility version 150.0.0, current version 550.19.0)
   /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation 
 (compatibility version 300.0.0, current version 751.21.0)
   /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 
 (compatibility version 45.0.0, current version 1038.29.0)
 TurboMonkey:~ tciuro$

The contents of the built app show:

 Last login: Wed Jun  2 11:11:14 on ttys000
 TurboMonkey:~ tciuro$ cd 
 /Users/tciuro/Desktop/Builds/Debug/RichEmailSender.app 
 TurboMonkey:RichEmailSender.app tciuro$ cd Contents/
 TurboMonkey:Contents tciuro$ ls -al
 total 16
 drwxr-xr-x  7 tciuro  staff  238 Jun  2 11:08 .
 drwxr-xr-x  3 tciuro  staff  102 Jun  2 11:08 ..
 drwxr-xr-x  4 tciuro  staff  136 Jun  2 11:08 Frameworks
 -rw-r--r--  1 tciuro  staff  906 Jun  2 11:08 Info.plist
 drwxr-xr-x  3 tciuro  staff  102 Jun  2 11:08 MacOS
 -rw-r--r--  1 tciuro  staff8 Jun  2 11:08 PkgInfo
 drwxr-xr-x  4 tciuro  staff  136 Jun  2 11:08 Resources
 TurboMonkey:Contents tciuro$ cd Frameworks/
 TurboMonkey:Frameworks tciuro$ ls -al
 total 0
 drwxr-xr-x  4 tciuro  staff  136 Jun  2 11:08 .
 drwxr-xr-x  7 tciuro  staff  238 Jun  2 11:08 ..
 drwxr-xr-x  6 tciuro  staff  204 Jun  2 11:08 EDCommon.framework
 drwxr-xr-x  6 tciuro  staff  204 Jun  2 11:08 EDMessage.framework
 TurboMonkey:Frameworks tciuro$ 

So the 

Where is zlib located?

2010-05-28 Thread Tito Ciuro
Hello,

I'm trying to incorporate zip-framework 
(http://code.google.com/p/zip-framework/) in my project. When I compile the 
sources in Xcode I see this error:

 inflate, referenced from:
 -readFromEntry:buffer:length: in ZipArchive.o
 
 inflateInit2, referenced from: -entryNamed: in ZipArchive.o
 
 ld: symbol(s) not found collect2: ld returned 1 exit status

The sources import zlib.h, so I guess I need to add zlib to my project, but I 
cannot find it. Where is it located?

Thanks,

-- Tito
___

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: Where is zlib located?

2010-05-28 Thread Tito Ciuro
Thanks a lot Roland!

-- Tito

On May 28, 2010, at 8:51 AM, Roland King wrote:

 libz.dylib
 
 it's the last thing listed in the list if I go 'add framework' - 'existing 
 frameworks'. 
 
 
 On 28-May-2010, at 2:40 PM, Tito Ciuro wrote:
 
 Hello,
 
 I'm trying to incorporate zip-framework 
 (http://code.google.com/p/zip-framework/) in my project. When I compile the 
 sources in Xcode I see this error:
 
 inflate, referenced from:
 -readFromEntry:buffer:length: in ZipArchive.o
 
 inflateInit2, referenced from: -entryNamed: in ZipArchive.o
 
 ld: symbol(s) not found collect2: ld returned 1 exit status
 
 The sources import zlib.h, so I guess I need to add zlib to my project, but 
 I cannot find it. Where is it located?
 
 Thanks,
 
 -- Tito
 ___
 
 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/rols%40rols.org
 
 This email sent to r...@rols.org
 

___

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

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

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

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


NSFileManager 'attributesOfItemAtPath:error:' does not traverse a link?

2010-05-28 Thread Tito Ciuro
Hello,

I'm trying to replace the following deprecated NSFileManager method:

 /* attributesOfItemAtPath:error: returns an NSDictionary of key/value pairs 
 containing the attributes of the item (file, directory, symlink, etc.) at the 
 path in question. If this method returns 'nil', an NSError will be returned 
 by reference in the 'error' parameter. This method does not traverse a 
 terminal symlink.
  
 This method replaces fileAttributesAtPath:traverseLink:.
  */
 - (NSDictionary *)attributesOfItemAtPath:(NSString *)path error:(NSError 
 **)error;


The old statement traverses the link:

NSDictionary* attr = [[NSFileManager defaultManager] 
fileAttributesAtPath:file traverseLink:YES];

The problem is that the header states that 'attributesOfItemAtPath:error:' that 
it's a replacement for 'fileAttributesAtPath:traverseLink:', but provides no 
provision for traversing the link.

How would I obtain the attributes of an item that needs to be traversed first?

Thanks,

-- Tito
___

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: NSFileManager 'attributesOfItemAtPath:error:' does not traverse a link?

2010-05-28 Thread Tito Ciuro
Thanks Charles!

-- Tito

On May 28, 2010, at 5:17 PM, Charles Srstka wrote:

 On May 28, 2010, at 10:01 AM, Tito Ciuro wrote:
 
 The old statement traverses the link:
 
  NSDictionary* attr = [[NSFileManager defaultManager] 
 fileAttributesAtPath:file traverseLink:YES];
 
 The problem is that the header states that 'attributesOfItemAtPath:error:' 
 that it's a replacement for 'fileAttributesAtPath:traverseLink:', but 
 provides no provision for traversing the link.
 
 How would I obtain the attributes of an item that needs to be traversed 
 first?
 
 You can easily traverse a link just by using [file 
 stringByResolvingSymlinksInPath] or [file stringByStandardizingPath] instead 
 of file. Where this gets tricky is if you *don’t* want to resolve the 
 symlink. Currently, the method doesn’t traverse symbolic links, but the 
 documentation claims that this behavior could change in a future version of 
 OS X, so if you need to guarantee that it won’t resolve, the only options are 
 either to use deprecated methods, or to use Carbon or BSD APIs.
 
 Charles

___

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

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

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

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


Re: Wondering about that iPad page curling

2010-04-07 Thread Tito Ciuro
How about this example? You can download the source as well:

http://www.devx.com/wireless/Article/42476/1763/page/3

-- Tito

On Apr 7, 2010, at 1:57 AM, Kiel Gillard wrote:

 Can UIViewAnimationTransitionCurlUp/Down be of any use?
 
 On 07/04/2010, at 2:10 AM, Alex Kac wrote:
 
 Well they may have done it with a private API for CoreImage if that exists 
 (not sure). THey may have done it with OpenGL. They may have taken their 
 CoreImage code on desktop and ported a part of it to iBooks and used that. 
 
 For you, most likely the best way to do it is using OpenGL.
 
 On Apr 6, 2010, at 10:56 AM, Laurent Daudelin wrote:
 
 So, no other response from the regular crowd of resident experts on how 
 Apple engineers did this?
 
 -Laurent.
 -- 
 Laurent Daudelin
 AIM/iChat/Skype:LaurentDaudelin 
 http://nemesys.dyndns.org
 Logiciels Nemesys Software  
 laurent.daude...@gmail.com
 Photo Gallery Store: 
 http://laurentdaudelin.shutterbugstorefront.com/g/galleries
 
 On Apr 5, 2010, at 18:32, Alex Kac wrote:
 
 Except CIFilter doesn't exist on the iPad in a public SDK setting.
 
 On Apr 5, 2010, at 8:22 PM, Laurent Daudelin wrote:
 
 On Apr 5, 2010, at 18:02, Graham Cox wrote:
 
 CIFilter has a page curl transition effect. Just map the 't' value to 
 the mouse/finger location.
 
 --Graham
 
 
 On 06/04/2010, at 10:55 AM, Laurent Daudelin wrote:
 
 I got my hands on an iPad today. I was really impressed with the 
 built-in book reader. When you flip the page while holding your finger 
 down, the page will curl and follow your finger. Very impressive! 
 Anybody has any idea how one would be able to achieve such effect?
 
 
 It's that easy?
 
 -Laurent.
 
 
 ___
 
 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/alex%40webis.net
 
 This email sent to a...@webis.net
 
 Alex Kac - President and Founder
 Web Information Solutions, Inc.
 
 The optimist proclaims that we live in the best of all possible worlds; and 
 the pessimist fears this is true.
 -- James Clabell
 
 
 
 
 ___
 
 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/kiel.gillard%40gmail.com
 
 This email sent to kiel.gill...@gmail.com
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/tciuro%40mac.com
 
 This email sent to tci...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Core Data dog-slow when using first time after boot

2009-08-19 Thread Tito Ciuro

Ruotger,

Interestingly enough, I experienced this behavior in my latest app  
which doesn't use Core Data. It uses SQLite directly instead. I  
recalled I had experienced this a long time ago (years ago) and  
someone (I don't remember who and where) mentioned a solution/ 
workaround/hack, which involves reading the file. Let's call this  
function warmUpFile():


FILE *my_stream = NULL;
const char *my_filename = ...;
size_t object_size = 1024;
size_t object_count = 1024;
char buf[object_size * object_count];

my_stream = fopen (my_filename, r);
while (fread (buf, object_size, object_count, my_stream)  0);
fclose (my_stream);

I have timed it both modes, always after rebooting my computer:

Reboot  Launch app  sqlite3_open_v2  do stuff == 35 seconds
Reboot  Launch app  warmUpFile()  sqlite3_open_v2  do stuff == 7  
seconds


Once warmUpFile() has been executed, let Core Data open the store and  
see if it helps.


-- Tito

On Aug 19, 2009, at 10:45 AM, Ruotger Skupin wrote:



Am 19.08.2009 um 19:18 schrieb I. Savant:



Hmm ... time to hit the books if you haven't already:

http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdPerformance.html#//apple_ref/doc/uid/TP40003468

Have you tried anything suggested there?



Fetch Limits: Not tried
The App basically loads objects and displays them in a table, so I  
can't fetch only half of them as sorting depends on the contents of  
the objects. I do fetches with sort descriptors though, to keep  
sorting time down (always below 0.1 sec).


Batch faulting: tried
It helps but it is still too slow.

Pre-fetching: not tried
But if I understand the document right it's just a special case of  
Batch Faulting and I don't see any faults fired since I use Batch  
Faulting anyway


Reducing Memory Overhead: most don't apply (Garbage Collection / no  
temporary managed objects)

I set the undo manager to nil

Large Data Objects (BLOBs): not used
I'd say all object are under 1k

Would switching to a different store type (other than SQL) help? The  
database is not that large (in my example 55MB) maybe an atomic  
store has its advantages there?


Ruotger

___

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/tciuro%40mac.com

This email sent to tci...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Core Data dog-slow when using first time after boot

2009-08-19 Thread Tito Ciuro

On Aug 19, 2009, at 2:21 PM, M Pulis wrote:

The sqlite question was a reference to tito saying his experience  
was years ago when the possibility of a non-native sqlite on an  
intel machine was absolutely real and significantly less surprising.  
You may know, but I have no idea what versions are installed on any  
given system, much less the OP's, responders, etc (you can execute  
PPC frameworks onto an Intel machine, yes?) what frameworks are in  
play, etc; and simply pose the question.


Even though I experienced this issue years ago in PPC, I'm currently  
running Intel and this behavior can still be seen. For the record, the  
database size is ~133MB.


-- Tito
___

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: NSTableView bug?

2009-07-02 Thread Tito Ciuro

On 2 Jul 2009, at 9:36 AM, Shawn Erickson wrote:

On Thu, Jul 2, 2009 at 8:37 AM, Michael Ashmichael@gmail.com  
wrote:
On Thu, Jul 2, 2009 at 10:51 AM, Chris Carsoncucar...@yahoo.com  
wrote:


Hello,

I've created a simple application with an NSTableView. I have  
written a delegate for this table,  
numberOfRowsInTableView:objectValueForTableColumn:row:, that  
returns the number of rows in the table when requested.


My application uses the table view to display hexadecimal data on  
a flash memory chip, with 16 bytes displayed per row. As a test, I  
tried returning a large number for the number of rows, 0x100.  
When I scroll through the table, everything looks okay for the  
first 14 million rows or so, after which the gray horizonal cell  
separator disappears and the row data begins to shift by a pixel  
per row, until it eventually is superimposed on the row above it.  
This seems like a bug with the NSTableView class, but perhaps I'm  
doing something wrong. Has anyone else run into this problem?


Known problem:

http://www.google.com/search?client=safarirls=en-usq=nstableview+14+millionie=UTF-8oe=UTF-8

Either restrict your app to running in 64-bit mode (which will cause
the graphics system to use doubles instead of floats) or write a
custom control.


...or seriously reconsider the utility (expectation) of having
millions of row in a table view.

Do users really want to scroll thru that many rows? Can users work
with that much data? etc.

In other words will this really be a problem without first causing
usability problems for your users.


Not to mention that dragging the scroll thumb one pixel will result in  
thousands of rows scrolled at once. Simply useless.


-- Tito
___

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: NSTableView bug?

2009-07-02 Thread Tito Ciuro

On 2 Jul 2009, at 9:56 AM, I. Savant wrote:


On Jul 2, 2009, at 12:52 PM, Tito Ciuro wrote:

Not to mention that dragging the scroll thumb one pixel will result  
in thousands of rows scrolled at once. Simply useless.


 Well, yes, but the only real way to avoid that is to design your  
application to limit the amount of data presented to the user. It's  
not an argument against the table view / scroll view mechanism so  
much as an argument against an overall UI approach that relies on  
that mechanism to display thousands and thousands of rows of data,  
which is rarely useful in itself ...


--
I.S.


I totally agree. I would never present anywhere that much info to the  
user. It's overwhelming and difficult to navigate through. My comment  
referred to a bad approach in design: I was adding another argument as  
to why displaying 14 million rows in a table view is a bad, bad idea.  
I don't see this as a limitation of NSTableView at all.


-- Tito
___

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: NSTableView bug?

2009-07-02 Thread Tito Ciuro

On 2 Jul 2009, at 11:10 AM, Greg Guerin wrote:

Hold down the Option key and drag the thumb.  It should micro  
scroll for as long as Option remains down.  This scroller gesture  
modifier has been around for a while.


Wow. Never heard about this one before. I wonder how many people know  
about this rather obscure feature?


-- Tito
___

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: API for fetching the computer name in cocoa

2009-06-12 Thread Tito Ciuro

Hi Arun,

How about -[NSProcessInfo hostname]? Check the following document for  
more info:


http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSProcessInfo_Class/Reference/Reference.html

Regards,

-- Tito

On Jun 11, 2009, at 11:58 PM, Graham Cox wrote:



On 12/06/2009, at 4:24 PM, Gerriet M. Denkmann wrote:



On 11 Jun 2009, at 18:55, Graham Cox graham@bigpond.com wrote:


On 12/06/2009, at 2:08 AM, Arun wrote:


Hi All,

Is there any API in cocoa which can be used to fetch computer name
which is
getting displayed in Finder?


I'm not sure if there's a better way, but you can use the Gestalt
function with the gestaltUserVisibleMachineName selector.


I tried:
SInt32 response = 0xdeadbeef;
OSErr resul1 = Gestalt( gestaltUserVisibleMachineName, 
response );
if ( resul1 != noErr )  //  error handling
		NSLog(@%s response = %ld = %#lx, __FUNCTION__, response,  
response);

and got no error and:
response = 1224224 = 0x12ae20

Where is my mistake?



I think this is not the right way to get the info you want after all  
- others have pointed out better APIs. According to the header for  
this:


enum {
   /*On Mac OS X, the user  
visible machine name may something like PowerMac3,4, which is*/
   /*a unique string for  
each signifigant Macintosh computer which Apple creates, but is*/
   /*not terribly useful as  
a user visible string.*/
 gestaltUserVisibleMachineName = 'mnam' /* Coerce response into a  
StringPtr to get a user visible machine name */

};

Obviously the meaning of machine name depends on what you think  
that means. A some point this was considered to be the model name. I  
think what you want is what the user has named it as visible on a  
network, etc.


But if you want to press on, the response is a StringPtr, which is a  
pointer to a pascal string. You'll need to convert that to an  
NSString, first by converting to a C string (generally easy to do -  
just append a /0 and take the pointer to the 1st character), then an  
NSString using a suitable encoding.


--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:
http://lists.apple.com/mailman/options/cocoa-dev/tciuro%40mac.com

This email sent to tci...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Simple Flipbook Animation?

2008-11-01 Thread Tito Ciuro

Hi Jeshua,

Is the CGImageRelease(im) in the for loop really needed? I think  
you're over-releasing the image in the array...


-- Tito

On Nov 1, 2008, at 10:26, Jeshua Lacock [EMAIL PROTECTED] wrote:



On Oct 31, 2008, at 12:13 PM, John Harper wrote:

I described how to do this using a CAKeyframeAnimation in a  
previous thread:


http://www.cocoabuilder.com/archive/message/cocoa/2008/8/3/214715


I am trying to adapt this technique for the iPhone SDK, but  
attempting to add the images NSArray to the KeyFrame animation  
causes my program to crash.


I heard that last week an iPhone dev list was created at Apple, but  
I have not been able to find it. I hope this is similar enough to be  
on-topic here, as I am using the same classes for the most part.


I can't find any examples that specify an image or array of images  
for the 'setValues' property.


NSArray *redExplode;
NSMutableArray *images;
images = [NSMutableArray array];
CGImageRef im;
UIImage *thisImg;
int p;

//frames ommitted for brevity
redExplode = [[NSArray arrayWithObjects:
  [UIImage imageNamed:@redExlode.0.png],
  [UIImage imageNamed:@redExlode.1.png],
  nil] retain];

for(p = 0;p[redExplode count];p++)
{
   thisImg = [redExplode objectAtIndex: p];
   im = thisImg.CGImage;
   [images addObject:(id)im];
   CGImageRelease (im);
}

[anim setKeyPath:@contents];
[anim setValues:images];
[anim setCalculationMode:@discrete];
[anim setRepeatCount:HUGE_VAL];

[[UIAnimator sharedAnimator] addAnimation:anim withDuration:1.5  
start:YES];



A backtrace reveals:

#0  0x950886ec in objc_msgSend ()
#1  0x9539d57f in NSPopAutoreleasePool ()
#2  0x953d6974 in __NSFireDelayedPerform ()
#3  0x96c10b45 in CFRunLoopRunSpecific ()
#4  0x96c10cf8 in CFRunLoopRunInMode ()
#5  0x31699d38 in GSEventRunModal ()
#6  0x31699dfd in GSEventRun ()
#7  0x30a5dadb in -[UIApplication _run] ()
#8  0x30a68ce4 in UIApplicationMain ()
#9  0x2d3c in main (argc=1, argv=0xbfffef68) at /Developer-3.1.0/ 
Examples/iPhone/MoveMe/main.m:53


The assembly that is crashing is:

0x950886ec  +0028  mov0x0(%edi),%esi


If I comment out the line [anim setValues:images];, the program  
does not crash.


Any ideas?


Thanks,

Jeshua Lacock
Founder/Programmer
3DTOPO Incorporated
http://3DTOPO.com
Phone: 877.240.1364

___

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/tciuro%40mac.com

This email sent to [EMAIL PROTECTED]

___

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 [EMAIL PROTECTED]


Re: Finding clicked row in NSOutlineView

2008-10-13 Thread Tito Ciuro

Hi James,

On Oct 13, 2008, at 6:23 PM, James Walker wrote:

I need to be notified when a row of an NSOutlineView was clicked,  
and find out which row.  Do I need to subclass it?  Just thought I'd  
ask, since I've read that new Cocoa programmers might tend to  
subclass more than they ought.


The NSOutlineViewSelectionDidChangeNotification is not sufficient,  
because in the case of a modified click that causes a multiple  
selection, I need to know the individual row that was clicked.


Check - (void)outlineViewSelectionDidChange:(NSNotification  
*)notification:


- (void)outlineViewSelectionDidChange:(NSNotification *)notification
{
NSInteger row = [mOutlineView selectedRow];
...
}

Don't forget to set the delegate.

-- Tito
___

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 [EMAIL PROTECTED]


Re: Sending a GET or POST HTTP request with Cocoa

2008-09-01 Thread Tito Ciuro

Hi Brad,

I'm just curious... having NSURLConnection and friends working, is  
there a specific reason you decided to switch to sockets? Is there  
something in Cocoa that you think is missing?


Cheers,

-- Tito

On Sep 1, 2008, at 9:02, Brad Gibbs [EMAIL PROTECTED] wrote:


You might find the discussion here helpful:

http://deusty.blogspot.com/search/label/NSURLRequest

After getting NSURL's to work, I decided I'd be better off with TCP  
sockets.  If you find yourself in the same position, you might try  
AsyncSockets (also available at the link above).  It's non-blocking,  
fast, easy and reliable.


Todd Ditchendorf also created some very useful tools for working  
with XMLRPC and SOAP servers, available here:


http://scan.dalo.us/


Brad


On Aug 31, 2008, at 9:30 AM, Sam Schroeder wrote:


Hi all,

I'm new to Cocoa development and I'm trying to learn the basics of
sending HTTP GETs and POSTs from Cocoa.  I've been reading up on  
NSURL

and searching for decent sample code.  However, I've been unable to
find something simple that _just_ explains how to send a GET and
capture the returned results.  My google_fu is weak.  My ultimate  
goal

is to send and receive XML (or maybe JSON) requests over HTTP, but
first I want to understand simple GETs and POSTs.

Any links or sample code would be greatly appreciated.

--
Thanks,

Sam
___

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/bradgibbs%40mac.com

This email sent to [EMAIL PROTECTED]


___

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/tciuro%40mac.com

This email sent to [EMAIL PROTECTED]

___

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 [EMAIL PROTECTED]


Re: NSString uppercaseString

2008-06-27 Thread Tito Ciuro

Hi Sam,

It's autoreleased. Make sure you read this document, as it'll answer  
many of your questions:


http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html 



-- Tito

On 27 Jun 2008, at 5:56 AM, Sam Mo wrote:


Newbie here:

I am looking at the documentation in Xcode for the method  
uppercaseString in
NSString class but it does not mention how the return NSString is  
being

released.

Will the return NSString be released when the originator be  
released? Or I
have to release the return NSString separately?  Or the return  
NSString will

just go away without any leak?

Thanks in advance for your help.
___

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/tciuro%40mac.com

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


Re: NSString uppercaseString

2008-06-27 Thread Tito Ciuro

Uli,

As Matt also points out, the documentation is not always crystal- 
clear, so I was simply trying to answer Sam's specific question. Since  
not all APIs behave the same way I added the link to the Memory  
Management Programming Guide for Cocoa page, hoping to help Sam. In  
any case, it was never my intention to spread inaccuracies :-)


Cheers,

-- Tito

On 27 Jun 2008, at 6:30 AM, Uli Kusterer wrote:


Am 27.06.2008 um 15:15 schrieb Tito Ciuro:

It's autoreleased.



No, there's no guarantee that it's autoreleased. All that's  
guaranteed is that you do not own it. This still means there'll be  
no leak and you shouldn't call release on it, but assuming it'  
autoreleased would be assuming a longer lifetime than is guaranteed.


If you read the documentation closely, you'll see that it would be  
perfectly valid to implement this method so the string goes away  
when the original (non-uppercase) string is released.


In the case of uppercaseString, it may actually *be* autoreleased  
under the hood, but that's an implementation detail. For example, - 
objectAtIndex: in NSArray* is documented the same way as  
uppercaseString, but if you release the array itsef, any object you  
obtained from the array goes away (unless you or someone else  
explicitly retain it).


So, it is NOT guaranteed to be autoreleased, it is just not owned  
by you. Please be careful about spreading inaccuracies not  
supported by the documentation.


Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de







___

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 [EMAIL PROTECTED]


Re: Accessors Question

2008-06-12 Thread Tito Ciuro

Hello,

Although I prefer the safer accessors, there has been one case where I  
had no choice but to return the main object pointer:


- (NSString *)foo
{
return foo;
}

In my app I had a method that was populating a custom cell with a few  
elements. Depending on the data source, I had to construct the strings  
in different ways. Since this string had to be constructed with up to  
5 elements, when the table view had many rows, performance suffered  
greatly during sort and memory consumption spiked tremendously due to  
a barrage of newly allocated objects.


I ended up writing something like:

// Private version used only for performance
- (NSString *)_foo
{
return foo;
}

// Safer version used in all other cases
- (NSString *)foo
{
return [[foo retain] autorelease];
}

By using '_foo' during sorting I increased speed noticeably, while  
reducing the memory footprint.


-- Tito

On 12 Jun 2008, at 11:27 AM, Jens Alfke wrote:



On 12 Jun '08, at 10:41 AM, Andy Lee wrote:


I hadn't thought of this case.
Thanks for the pointer to the docs -- I now see there is a  
vulnerability in the accessors I've been writing.


This is kind of a religious issue. Some people like the safer  
accessors. Some people see them as a very expensive* workaround for  
a problem that rarely occurs.


I'm firmly in the latter camp. I've never used this 'safe' form of  
accessor, and have only rarely run into the kind of crash it  
prevents; and it was always pretty easy to track down and fix. (The  
fix is just for the caller to retain the value it got from the  
accessor, then release it when it's done using it.)


Another alternative is to leave the getters simple, but change the  
_setter_ methods to autorelease the old value instead of releasing  
it; that prevents this same crash, but is less expensive because  
setters are much more rarely called than getters (and -autorelease  
isn't much more expensive than -release.)


—Jens

* A basic accessor requires one or two machine instructions to do  
the actual work; whereas -retain and -autorelease involve extra  
method dispatches that each acquire a global lock and do a hashtable  
lookup. Obviously any one call isn't going to take a noticeable  
amount of time, but accessor calls are so damn ubiquitous that this  
can have an overall impact on app performance in some cases. Not to  
mention memory usage, since autoreleased objects have a longer  
lifespan and can build up during  
loops.___


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/tciuro%40mac.com

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


Re: Accessing Directory.app shared contacts

2008-04-12 Thread Tito Ciuro

Hi Kyle,

On 11 Apr 2008, at 4:50 PM, Kyle Sluder wrote:


Hey all,

Is there a way to get at the contacts available in Directory.app?  The
disjunction between Directory.app and Address Book.app is infuriating,
to say the least.  I really want to develop a quick-and-dirty in house
contact management app that integrates nicely with all the other
collaboration features, but it looks like I'm going to be crawling
LDAP servers to do so.


The data is stored in the OpenDirectory respository. Shared Contacts  
are stored under 'People'. You'll probably need to use the Directory  
Services API to manipulate the data.


-- Tito

___

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 [EMAIL PROTECTED]