Re: looks like my syntax is wrong. Does not compile
On Jul 3, 2009, at 9:29 PM, Agha Khan wrote: NSNumber* aNumber = [Aobject _Edge] numberWithInt:j; // looks like my syntax is wrong. Does not compile Objective-C isn't smalltalk. All message expressions have to be enclosed in square brackets: NSNumber* aNumber = [[Aobject _Edge] numberWithInt:j]; -jcr ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Send files from iphone
Hello Development, Saturday, July 4, 2009, 3:20:45 AM, you wrote: I need to be able to upload the data from a UIImage to a server via http POST however I simply cannot find a good example of how to arrange the headers or how to make this post. The only data I need to send to the server is the file's name, the user's name and the data itself and I simply cannot seem to get it to work. Can any of you offer a helping hand? I don't know if CoreFoundation stuff is available on iPhone but if it is, CFHTTPMessage is an excellent way to do HTTP POST. Best regards, Petermailto:darkmat...@blueyonder.co.uk ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
NSData. add 6 bytes to NSData
Hi, everybody, I need to add 6 bytes to my NSData steps: 1. write into NSData NSData *data = [NSData dataWithBytes:(const char*)packet length:sizeof(packet)]; 2. read from NSData 3. In loop i need to add 6 bytes 4. And again wtite into NSData first step i did, and from 2 to 4 i dont know how to do. Anybody could help me? Thanks in advance! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: NSData. add 6 bytes to NSData
Hello Carlo, Saturday, July 4, 2009, 12:47:31 PM, you wrote: Hi, everybody, I need to add 6 bytes to my NSData steps: 1. write into NSData NSData *data = [NSData dataWithBytes:(const char*)packet length:sizeof(packet)]; 2. read from NSData 3. In loop i need to add 6 bytes 4. And again wtite into NSData first step i did, and from 2 to 4 i dont know how to do. Anybody could help me? Thanks in advance! You can't. Use NSMutableData instead. -- Best regards, Petermailto:darkmat...@blueyonder.co.uk ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Send files from iphone
I'm not quite sure about whether Available in Mac OS X version 10.1 and later means that it's not available in iPhone OS. But, I assume everything that exists on iPhone OS reference library, exists on iPhone OS, because that's also the case with NSURLConnection, which obviously exists on iPhone OS. Jesse Armand (http://jessearmand.com) On Sat, Jul 4, 2009 at 6:58 PM, Peter Mulhollanddarkmat...@blueyonder.co.uk wrote: Hello Development, Saturday, July 4, 2009, 3:20:45 AM, you wrote: I need to be able to upload the data from a UIImage to a server via http POST however I simply cannot find a good example of how to arrange the headers or how to make this post. The only data I need to send to the server is the file's name, the user's name and the data itself and I simply cannot seem to get it to work. Can any of you offer a helping hand? I don't know if CoreFoundation stuff is available on iPhone but if it is, CFHTTPMessage is an excellent way to do HTTP POST. Best regards, Peter mailto:darkmat...@blueyonder.co.uk ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/mnemonic.fx%40gmail.com This email sent to mnemonic...@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
NSLinkAttributeName: can I control the visual presentation?
I have a mutable attributed string that is displayed in an NSTextView. For a certain range, I set several attributes, including NSLinkAttributeName. However, the presentation shows as blue underlined text even though I have set other attributes for the font color and also have set the underline style to none. Is there something else I must do to control the visual presentation? Or am I going to need to use tracking areas and manage this with dynamic changes? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
leaking UIColor objects
Hello all, my iPhone OS 3.0 app uses UIColor objects to set the colors of various objects (text colors of labels, cell view backgrounds, and segmented control tint colors), but I *never* store any of these colors as ivars. In other words, I *only* do things like label.textColor = [UIColor blueColor]; Now, after I installed 3.1 beta, **but still building under 3.0**, Instruments/Leaks tells me that my app is leaking UIColor objects. My app was leak-free under 3.0 Leaks. My conclusion is that Instruments (or, at least, Leaks) has changed from 3.0 to 3.1 beta. I'm planning to report this as a bug, but I thought I'd ask the community first, to make sure that this isn't something I'm overlooking in my own code or elsewhere. And, yes, I realize that discussing beta releases is a no-no. I'm not asking for a discussion; I'm merely asking for a I'm having that problem too and I've already filed a radar or Yes, this looks like a bug and you should report it or a No, it must be something in your code kind of response. Thanks in advance. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
leaking UIColor objects (correction)
Actually, Leaks reports that my app is leaking UICGColor objects, not UIColor objects. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: leaking UIColor objects
On 4 Jul 2009, at 8:27 AM, WT wrote: And, yes, I realize that discussing beta releases is a no-no. I'm not asking for a discussion; I'm merely asking for a I'm having that problem too and I've already filed a radar or Yes, this looks like a bug and you should report it or a No, it must be something in your code kind of response. Sigh. Soliciting publicity for the behavior of pre-release software is a violation of Apple's NDA, no matter how you parse discussing. Common sense would say you could get an answer at devforums.apple.com. Also, if you're seeing changes in the behavior of an API -- and is that surprising in beta software -- it's no disgrace to file a bug report, no matter whether you think others have seen the bug. — F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: NSLinkAttributeName: can I control the visual presentation?
On Jul 4, 2009, at 9:18 AM, Stuart Malin wrote: I have a mutable attributed string that is displayed in an NSTextView. For a certain range, I set several attributes, including NSLinkAttributeName. However, the presentation shows as blue underlined text even though I have set other attributes for the font color and also have set the underline style to none. Is there something else I must do to control the visual presentation? On NSTextView: - (void)setLinkTextAttributes:(NSDictionary *)attributeDictionary; - (NSDictionary *)linkTextAttributes; Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Send files from iphone
CoreFoundation exists on the iPhone. And you can look at cocoadev.org for a decent HTTP Post example there or look on Google code for a class that does Flickr uploads through HTTP Post and that works on the iPhone. HTTP Post is not hard, but it does expect a very specific way of doing it. On Jul 4, 2009, at 7:46 AM, Jesse Armand wrote: I'm not quite sure about whether Available in Mac OS X version 10.1 and later means that it's not available in iPhone OS. But, I assume everything that exists on iPhone OS reference library, exists on iPhone OS, because that's also the case with NSURLConnection, which obviously exists on iPhone OS. Jesse Armand (http://jessearmand.com) On Sat, Jul 4, 2009 at 6:58 PM, Peter Mulhollanddarkmat...@blueyonder.co.uk wrote: Hello Development, Saturday, July 4, 2009, 3:20:45 AM, you wrote: I need to be able to upload the data from a UIImage to a server via http POST however I simply cannot find a good example of how to arrange the headers or how to make this post. The only data I need to send to the server is the file's name, the user's name and the data itself and I simply cannot seem to get it to work. Can any of you offer a helping hand? I don't know if CoreFoundation stuff is available on iPhone but if it is, CFHTTPMessage is an excellent way to do HTTP POST. Best regards, Petermailto:darkmat...@blueyonder.co.uk ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/mnemonic.fx%40gmail.com This email sent to mnemonic...@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/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/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData. add 6 bytes to NSData
thanks for your reply, could you show me simple example how to add binary data to existing data and also to add header of 2 bytes i've been trying to use buffer but i have a troubles with result my code: #define PROTO_VERSION_MAJOR 1 #define PROTO_VERSION_MINOR 7 #define PROTO_VERSION u_long)(PROTO_VERSION_MAJOR))16)|(u_long)(PROTO_VERSION_MINOR)) #define PROTO_MAJOR(p) (((p)0x)16) #define PROTO_MINOR(p) ((p)0x) typedef struct mrim_packet_header_t { u_long magic; u_long proto; u_long seq; u_long msg; u_long dlen; u_longfrom; u_longfromport; u_charreserved[16]; } mrim_packet_header_t; #define CS_MAGIC0xDEADBEEF #define MRIM_CS_HELLO 0x1001 structmrim_packet_header_tpacket; packet = [self makePacket:MRIM_CS_HELLO length:0]; NSMutableData *data = [NSData dataWithBytes:packet length:sizeof(packet)]; int c = 4; char buf[c]; [data getBytes:buf]; int i; for (i=20; i[data length]+c; i++) { buf[i] = 0; } data = [NSData dataWithBytes:buf length:[data length]+c]; } -(struct mrim_packet_header_t) makePacket:(unsigned long)key length:(unsigned long)len { staticunsignedlongseq = 2; mrim_packet_header_tmrim_head; //memset(mrim_head, 0, sizeof (mrim_head)); mrim_head.magic = CS_MAGIC; mrim_head.proto = PROTO_VERSION; mrim_head.seq = seq; mrim_head.msg = key; mrim_head.dlen = len; //mrim_head.from = h; //mrim_head.fromport = 2041; seq++; return mrim_head; } so, i found a dump of binary which must to result efbeadde 13000100 0200 0110 0010 0020 but i got efbeadde 07000100 0110 00286930 4cc4 58e4ffbf 36c90091 my data is different of correct data, why? I use the same variables like there ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: leaking UIColor objects
On Jul 4, 2009, at 4:37 PM, Fritz Anderson wrote: On 4 Jul 2009, at 8:27 AM, WT wrote: And, yes, I realize that discussing beta releases is a no-no. I'm not asking for a discussion; I'm merely asking for a I'm having that problem too and I've already filed a radar or Yes, this looks like a bug and you should report it or a No, it must be something in your code kind of response. Soliciting publicity for the behavior of pre-release software is a violation of Apple's NDA, no matter how you parse discussing. I am not soliciting publicity. Suppose someone sent a message to the list saying AppleOS 17.3 beta SDK is available for download (assuming such a thing existed). Does that qualify as soliciting publicity? As a violation of Apple's NDA? Both? Neither? There is a line, but where is it drawn? My point is that there is a certain latitude in how the word discussing can be parsed. The part of my message that you quoted represents an acknowledgement on my part that I am in that grey area surrounding the line where it's not clear whether or not what I'm doing is a violation of Apple's NDA. I may have made a mistake in sending my original message to cocoa-dev but, if so, it was an honest mistake based on the intention of minimizing the filing of frivolous bug reports. Pardon me for thinking too much. you could get an answer at devforums.apple.com. A constructive suggestion. Thank you. Also, if you're seeing changes in the behavior of an API -- and is that surprising in beta software -- it's no disgrace to file a bug report, no matter whether you think others have seen the bug. Whether or not others have seen this behavior is not my motivation. I'm simply trying to ascertain if I'm missing something, in order to avoid filing a bug report for something that might be a mistake or misunderstanding on my part. What would happen if people were to file bugs for every misunderstanding they have? Moreover, considering that I'm still building and running under 3.0 (a fact you seem to have missed), this is not a change in behavior of an API, unless you consider Leaks to be part of the API. I obviously didn't consider it to be, and that might have been another mistake. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: NSData. add 6 bytes to NSData
In all honesty the easiest way is to do it in C. Add a 4 byte variable to the top of your packet header.. When building the packet set it to 0.. That solves your problem of getting data into the packet. But if you want to add something to the beginning, using NSMutableData, you have to first create the NSMutableData packet with 4 bytes of 0s then call [data appendBytes].. So something like so (not perfect).. char bytes[4] = {0,0,0,0}; NSMutableData* data = [NSMutableData withBytes:bytes length:sizeof (bytes)]; [data appendBytes:packet length:sizeOfPacket]; But i think you better way is to just put the 4 bytes at the top of your packet description. When creating you can set it to 0's (first call should be memset in your make packet call to set things to 0). If you are reading the packet from another location you can then put the pointer for the read or memcpy to the location of the first field. NSData is nice but i still think most memory management things (like creating and dealing with buffers) are better in C then thrown into an NSData if needed.. I generally don't use NSData as 1st class citizen for generating buffers. Scott Andrew On Jul 4, 2009, at 9:23 AM, Carlo Gulliani wrote: thanks for your reply, could you show me simple example how to add binary data to existing data and also to add header of 2 bytes i've been trying to use buffer but i have a troubles with result my code: #define PROTO_VERSION_MAJOR 1 #define PROTO_VERSION_MINOR 7 #define PROTO_VERSION u_long)(PROTO_VERSION_MAJOR))16)|(u_long) (PROTO_VERSION_MINOR)) #define PROTO_MAJOR(p) (((p)0x)16) #define PROTO_MINOR(p) ((p)0x) typedef struct mrim_packet_header_t { u_long magic; u_long proto; u_long seq; u_long msg; u_long dlen; u_longfrom; u_longfromport; u_charreserved[16]; } mrim_packet_header_t; #define CS_MAGIC0xDEADBEEF #define MRIM_CS_HELLO 0x1001 structmrim_packet_header_tpacket; packet = [self makePacket:MRIM_CS_HELLO length:0]; NSMutableData *data = [NSData dataWithBytes:packet length:sizeof (packet)]; int c = 4; char buf[c]; [data getBytes:buf]; int i; for (i=20; i[data length]+c; i++) { buf[i] = 0; } data = [NSData dataWithBytes:buf length:[data length]+c]; } -(struct mrim_packet_header_t) makePacket:(unsigned long)key length: (unsigned long)len { staticunsignedlongseq = 2; mrim_packet_header_tmrim_head; //memset(mrim_head, 0, sizeof (mrim_head)); mrim_head.magic = CS_MAGIC; mrim_head.proto = PROTO_VERSION; mrim_head.seq = seq; mrim_head.msg = key; mrim_head.dlen = len; //mrim_head.from = h; //mrim_head.fromport = 2041; seq++; return mrim_head; } so, i found a dump of binary which must to result efbeadde 13000100 0200 0110 0010 0020 but i got efbeadde 07000100 0110 00286930 4cc4 58e4ffbf 36c90091 my data is different of correct data, why? I use the same variables like there ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/scottandrew%40roadrunner.com This email sent to scottand...@roadrunner.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: [Moderator] Re: Securely limit the running an application by serial number
I don't see how this is a business question, it's very technical. On Sat, Jul 4, 2009 at 7:23 AM, Scott Anguish sc...@cocoadoc.com wrote: the discussion of software protection is off-limits for this list. take to to the mac small business list. [moderator] On 2009-07-03, at 6:48 PM, Peter Mulholland wrote: I want my application to run on specific computers that are licensed to use the software. This is for limited use, and isn't a product for the masses. I've realized that you can limit the software to run on specific computers by limiting using the serial number of the machine. how secure is it? can someone crack the software by avoiding the if statement that does the check? How can I secure my checks. First thing - Apple and their devout followers will tell you don't do that when it comes to ANY protection. Ironic since as they have DSMOS and PT_DENY_ATTACH on iTunes etc. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: NSData. add 6 bytes to NSData
On Jul 4, 2009, at 10:56 AM, Scott Andrew wrote: In all honesty the easiest way is to do it in C. Add a 4 byte variable to the top of your packet header.. When building the packet set it to 0.. That solves your problem of getting data into the packet. But if you want to add something to the beginning, using NSMutableData, you have to first create the NSMutableData packet with 4 bytes of 0s then call [data appendBytes].. So something like so (not perfect).. Maybe I missed your point, but you can easily insert bytes in an NSMutableData. Check the documentation for -[NSMutableData replaceBytesInRange:withBytes:length:]. On Jul 4, 2009, at 9:23 AM, Carlo Gulliani wrote: NSMutableData *data = [NSData dataWithBytes:packet length:sizeof (packet)]; Note that this is /not/ an NSMutableData, in spite of the declaration, since you've used NSData to create it. Use [NSMutableData dataWithBytes:length:] to create a mutable data instance. -- Adam smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: NSData. add 6 bytes to NSData
Carlo Gulliani wrote: typedef struct mrim_packet_header_t { u_long magic; Your use of u_long as a 32-bit value will likely fail if your code is ever compiled for 64-bit. You should use the typedef'ed names that have an explicit size-number in them, like uint32_t, uint64_t. NSMutableData *data = [NSData dataWithBytes:packet length:sizeof (packet)]; This is wrong. You can't make an NSData into an NSMutableData simply by assigning it to a variable of that type. You should re-read the fundamentals of Objective-C. Then you should the class reference doc for NSMutableData. int c = 4; char buf[c]; [data getBytes:buf]; This is a buffer overflow. The variable 'buf' is only 4 bytes long, but getBytes: copies the entire length of 'data' into buf. for (i=20; i[data length]+c; i++) { buf[i] = 0; } This is another buffer overflow. You are zeroing elements far beyond the last real element of buf. data = [NSData dataWithBytes:buf length:[data length]+c]; This is another buffer overflow. It's creating an NSData with random stuff from well beyond the end of the buf array. so, i found a dump of binary which must to result efbeadde 13000100 0200 0110 0010 0020 but i got efbeadde 07000100 0110 00286930 4cc4 58e4ffbf 36c90091 my data is different of correct data, why? I use the same variables like there No, you didn't use the same variables. You're not using the same value for the proto member (you use 0x10007, the reference data shows 0x10013). You didn't build your header with a dlen of 16 (0x10), which is what the reference data shows. You built it with a dlen of 0 [self makePacket:MRIM_CS_HELLO length:0];. One of the buffer overflows is the most likely cause of the remaining differences. You should review the fundamentals of C structs, C memory layouts, and why uninitialized local variables aren't automatically zeroed. Once you get the memory contents correct in plain old C, it will be easy to make a correct NSData that contains the data. You're not even close to getting the correct C memory layout, though, and anything you're doing with NSData isn't helping solve that problem at all. You should ignore NSData completely at this point and focus on getting the correct memory buffer contents, with no buffer overflows. -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: [Moderator] Re: Securely limit the running an application by serial number
It's something that has been over and over on this list in the past. The discussion of software protection and licensing schemes simply belongs there. There is a Yahoo Group for discussion of business-related issues at: http://groups.yahoo.com/group/macsb/ [moderator] On 2009-07-04, at 2:13 PM, Ammar Ibrahim wrote: I don't see how this is a business question, it's very technical. On Sat, Jul 4, 2009 at 7:23 AM, Scott Anguish sc...@cocoadoc.com wrote: the discussion of software protection is off-limits for this list. take to to the mac small business list. [moderator] On 2009-07-03, at 6:48 PM, Peter Mulholland wrote: I want my application to run on specific computers that are licensed to use the software. This is for limited use, and isn't a product for the masses. I've realized that you can limit the software to run on specific computers by limiting using the serial number of the machine. how secure is it? can someone crack the software by avoiding the if statement that does the check? How can I secure my checks. First thing - Apple and their devout followers will tell you don't do that when it comes to ANY protection. Ironic since as they have DSMOS and PT_DENY_ATTACH on iTunes etc. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Unit Testing and Run Loops
Hello all, I've looked around for writing about this, but I can't really find anybody who has declared the absolutely right solution to this problem. I'm using the SenTesting kit and writing a class that initiates a web download, async using the run loop. How can I write a unit test that makes sure that the class completes the download? The test case will only run once, and threads in the unit test tool don't appear to have run loops, or if they do, they don't appear to iterate. I've walked friends through this problem before, and the best solution we came up with is to rewrite all our code as synchronous but inside and NSOperation, and then we unit test the operations to make sure they work, and in the app we run the operations through an operation queue. But does anyone know how to setup something like a stream read or URL download, and make sure run loop completely services the download/ stream, and then write a unit test that makes sure all this happens? Jamie ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Fwd: Unit Testing and Run Loops
Thanks, I dimly recall seeing something like this before... On Jul 4, 2009, at 12:19 PM, A.M. wrote: On Jul 4, 2009, at 3:10 PM, Jamie Hardt wrote: [...] But does anyone know how to setup something like a stream read or URL download, and make sure run loop completely services the download/stream, and then write a unit test that makes sure all this happens? NSTimeInterval timeout=3.0; while(1) { NSTimeInterval runtime=[NSDate timeIntervalSinceReferenceDate]; [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate: [NSDate dateWithTimeIntervalSinceNow:t timeout]; timeout-=[NSDate timeIntervalSinceReferenceDate]-runtime; if(mFileDownloaded || timeout0.0) break; } STAssertTrue(mFileDownloaded==YES,@File failed to download); 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
Re: Animation Did Stop - Works For OS3 but not OS2.2
Hi, I would highly recommend that you move this thread to the iPhone Developer Forums. This is the Cocoa Dev mailing list. -Conrad On Fri, Jul 3, 2009 at 3:37 PM, Dave DeLong davedel...@me.com wrote: Hi Chunk, You're missing the third parameter of the selector (the context parameter). Also, I believe that OS 2.2 didn't send parameters along in the animation selectors. The selector you're providing (animationHasFinished:finished:) will need at least two (the docs for 3.0 say you need 3), but IIRC, OS 2.2 needs the selector to be more like: @selector(animationDidStop). HTH, Dave On Jul 2, 2009, at 10:25 PM, Chunk 1978 wrote: this works fine in OS 3, but it doesn't call fade out in OS2.2? what is the problem? - (void)animationHasFinished:(NSString *)animationID finished:(BOOL)finished { if ((animationID == @FadeIn) finished) { [self fadeOut]; } } - (void)fadeIn { [UIView beginAnimations:@FadeIn context:NULL]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector (animationHasFinished:finished:)]; [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; [UIView setAnimationDuration:0.05]; [self.flashView setAlpha:1.0]; [UIView commitAnimations]; } - (void)fadeOut { [UIView beginAnimations:@FadeOut context:NULL]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; [UIView setAnimationDuration:0.45]; [self.flashView setAlpha:0.0]; [UIView commitAnimations]; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/conradwt%40gmail.com This email sent to conra...@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: NSString stringWithFormat: and strings
On Jul 3, 2009, at 8:27 PM, Andy Lee wrote: On Jul 3, 2009, at 11:20 PM, KK wrote: Hello, I have a NSString (from a property list file) that has the %@ formats in it... So.. I do something like this: NSString *stringFromPlistFile; NSString *newString = [NSString stringWithFormat:stringFromPlistFile, @Hello]; But that doesn't work... What do you mean doesn't work? What *happens*? Yeah, what Andy said. Try this: NSString *format = @%@, %...@!; NSString *hello = @Hello; NSString *world = @world; NSString *result = [NSString stringWithFormat:format, hello, world]; NSLog(@result: %@, result); Then use similar techniques to debug your situation. -- For the fly-blown words that make me spew Still in his ears were holy, And he was born knowing what I had learned Out of books and slowly. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Can we pass pointer of a class to a function?
I am passing a valid data pointer to a function and I am getting exception. Before I go further I just like to know if it is possible? -Agha ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Movable Document Modal Dialogs
On Fri, 3 Jul 2009 14:23:04 -0400, Development developm...@midnightmage.com said: For our application (think of it as a drawing program), the user sometimes NEEDS to be able to view the document under the modal dialog. We can not use sheets, because they cover up the document window itself. Not necessarily. It is a delightful, yet little-known, fact that sheets can emerge from *anywhere* on a window - not merely from its top. So why not have the sheet emerge from a spot on the window where it won't cover any important info? For example you could have the sheet emerge from the *lower edge* of the window. (If the window is low on the screen, it moves upwards automatically to permit the display of the sheet.) This is unusual but only because (IMHO) not enough developers take advantage of this feature! :) m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Can we pass pointer of a class to a function?
On Jul 4, 2009, at 2:53 PM, Agha Khan agha.k...@me.com wrote: I am passing a valid data pointer to a function and I am getting exception. Before I go further I just like to know if it is possible? Short answer, yes. Classes are objects too. But classes aren't always appropriate arguments to a method. You need to post your code. --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: Sorting an editable tableView of managed object
On Fri, 03 Jul 2009 17:00:59 -0500, Steve Cronin steve_cro...@mac.com said: Folks; I have a simple one column tableView of a managed object. The text field in the table view is editable. I want to keep the table sorted when the user manually changes a value, //there is NO binding to a sortDesctiptor Why not? If there were, then you would just tell the array controller to rearrangeObjects - a one-liner. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Sorting an editable tableView of managed object
Matt; Thanks that did the trick! I didn't add the binding because I only want to add bindings when I understand the value of doing so. In this case the table column headers all performed their various sorts as expected without the bindings - hence no bound sortDescriptors. Adding the binding does get the UI job done but leaves me at a dead end in my understanding of why the code I submitted doesn't accomplish my goal! Thanks for your time and help! Steve On Jul 4, 2009, at 5:51 PM, Matt Neuburg wrote: On Fri, 03 Jul 2009 17:00:59 -0500, Steve Cronin steve_cro...@mac.com said: Folks; I have a simple one column tableView of a managed object. The text field in the table view is editable. I want to keep the table sorted when the user manually changes a value, //there is NO binding to a sortDesctiptor Why not? If there were, then you would just tell the array controller to rearrangeObjects - a one-liner. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Yet another memory management question
Is this the right way to do it? - (void)viewDidLoad { id myObject = [[NSObject alloc] init]; } - (void)viewDidUnload { [myObject release]; myObject = nil; } - (void)dealloc { [myObject release]; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Optimizing writes of big files for specific hardware?
On Fri, Jul 3, 2009 at 5:07 PM, Jay Reynolds Freemanjay_reynolds_free...@mac.com wrote: On Jul 3, 2009, at 1:20 PM, Greg Guerin wrote: [useful comments excised, thank you very much] I will try lseek and write at the end. Exactly what problem is solved by initially writing multiple gigabytes of zeros to disk? As for what I am doing, I have a parallel Scheme system (Wraith Scheme, see the Software page of my web site, URL in the .sig), and I use mmap to obtain a shared Scheme main memory. By parallel, I mean separate Unix processes, not threads. I am setting things up so that a user who wishes to do so can choose a memory size large enough to drag the application to a screeching halt from swapping, and the way to do that seems to be for one process to create a file of the desired size, then have that process and all the others mmap it. I am not saying that it is wise to choose such a large Scheme main memory, but some users may want to do it. If there is a better way, I would love to hear about it; I am by no means an mmap wizard. You can do shared memory without requiring the entire shared memory space to be backed by a file on your hard drive. There is a POSIX API for shared memory which you can get to by googling POSIX shared memory or looking up the man page for the shm_open function. You can also do shared memory using mach calls, but I don't actually know what those calls are. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Yet another memory management question
On Jul 5, 2009, at 4:39 AM, DKJ wrote: Is this the right way to do it? Not quite... - (void)viewDidLoad { id myObject = [[NSObject alloc] init]; } Your myObject is a local variable, so it will go out of scope when viewDidLoad returns. That means you won't be able to refer to the object it points to in other methods (such as viewDidUnload and dealloc). The following is ok, though, assuming that you have appropriately declared myObject in your class (for example, as an instance variable): - (void)viewDidLoad { myObject = [[NSObject alloc] init]; } Note the absence of 'id'. - (void)viewDidUnload { [myObject release]; myObject = nil; } - (void)dealloc { [myObject release]; } Both are fine, but I would suggest something like the following, just because it avoids code duplication: - (void)viewDidUnload { [self dispose]; } - (void)dealloc { [self dispose]; // deallocation of stuff that was not unloaded [otherStuff release]; } - (void)dispose { [myObject release]; myObject = nil; } You can have -dispose be a private method of your class so it won't be accessible outside of it. One big advantage of this separation is that if/when you need to change your deallocations, you only have to do it in one place. I would recommend that you read the Cocoa Memory Management Guide for all the details on memory management: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Yet another memory management question
In fact I'm now going through my code line-by-line, checking all the alloc, retain, copy etc. statements. While doing so I've come across another thing that puzzles me. Xcode very kindly provides template code when I create new files for classes like UIViewController. (But this is still a Cocoa question.) In the template code for viewDidLoad, it provides [super viewDidLoad]. But there is no corresponding [super viewDidUnload] in the template code for viewDidUnload. Should it be there anyway? dkj ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Yet another memory management question
On Jul 5, 2009, at 5:34 AM, DKJ wrote: In fact I'm now going through my code line-by-line, checking all the alloc, retain, copy etc. statements. While doing so I've come across another thing that puzzles me. Xcode very kindly provides template code when I create new files for classes like UIViewController. (But this is still a Cocoa question.) In the template code for viewDidLoad, it provides [super viewDidLoad]. But there is no corresponding [super viewDidUnload] in the template code for viewDidUnload. Should it be there anyway? dkj My guess is that it should, but guessing is not necessary. Just add it, because it won't hurt if it isn't needed and it will do the right thing if it is. Not adding it, on the other hand, might do the wrong thing if it is needed. You might also want to file a bug report, pointing out the apparent discrepancy. Just as an aside, I typically write my code using the socks and shoes mentality. You put your socks in first and your shoes last, but you take off your shoes first and your socks last. So, I usually write - (void) viedDidLoad { [super viewDidLoad]; // load my stuff } - (void) viedDidUnload { // unload my stuff [super viewDidUnload]; } Note how calling the super implementation comes first in viewDidLoad but last in viewDidUnload. I use the same approach for other pairs of closely related methods, such as viewWillAppear/viewWillDisappear and viewDidAppear/viewDidDisappear. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Yet another memory management question
On Jul 4, 2009, at 8:11 PM, WT wrote: The following is ok, though, assuming that you have appropriately declared myObject in your class (for example, as an instance variable): - (void)viewDidLoad { myObject = [[NSObject alloc] init]; } In general, this is not recommended. If you manipulate an instance variable anywhere other than in an initialiser or a dealloc method, you should use a suitable accessor method. - (void)viewDidLoad { id anObject = [[NSObject alloc] init]; [self setMyObject:anObject]; [anObject release]; } Both are fine, but I would suggest something like the following, just because it avoids code duplication: - (void)viewDidUnload { [self dispose]; } It is not clear here what is the benefit of avoiding code duplication -- you're simply introducing another method that you have to keep track of. - (void)dealloc { [self dispose]; // deallocation of stuff that was not unloaded [otherStuff release]; } This is missing: [super dealloc]; as the final statement; - (void)dispose { [myObject release]; myObject = nil; } Again, you should use accessor methods rather than direct variable manipulation. You can have -dispose be a private method of your class so it won't be accessible outside of it. One big advantage of this separation is that if/when you need to change your deallocations, you only have to do it in one place. Referring to this as deallocations is at best misleading. The goal is to relinquish ownership of any objects you're holding on to. This may or may not result in deallocation of those objects. mmalc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Yet another memory management question
On 4-Jul-09, at 21:10 , mmalc Crawford wrote: you should use accessor methods rather than direct variable manipulation Would declaring all the variables as properties, and then synthesising them, take care of this? If so, what should I do in dealloc for those variables? For example, suppose I've got this in the header: NSArray *myArray; ... @property(retain) NSArray *myArray; And this in the implementation file: @synthesize myArray; Should dealloc have this: [myArray release]; or something like this: self.myArray = nil; Sorry for all these beginner questions; but they will probably prevent a lot more questions later on. dkj ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Yet another memory management question
On Jul 4, 2009, at 9:31 PM, DKJ wrote: On 4-Jul-09, at 21:10 , mmalc Crawford wrote: you should use accessor methods rather than direct variable manipulation Would declaring all the variables as properties, and then synthesising them, take care of this? Strictly, this is an orthogonal issue. Declaring and synthesising properties creates the accessor methods; you still have to invoke them when appropriate. If so, what should I do in dealloc for those variables? For example, suppose I've got this in the header: NSArray *myArray; ... @property(retain) NSArray *myArray; And this in the implementation file: @synthesize myArray; Should dealloc have this: [myArray release]; or something like this: self.myArray = nil; In an initaliser method and in dealloc, you should typically set or release the variable directly, so in dealloc it would be [myArray release]; mmalc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Yet another memory management question
On Jul 5, 2009, at 6:10 AM, mmalc Crawford wrote: On Jul 4, 2009, at 8:11 PM, WT wrote: The following is ok, though, assuming that you have appropriately declared myObject in your class (for example, as an instance variable): - (void)viewDidLoad { myObject = [[NSObject alloc] init]; } In general, this is not recommended. If you manipulate an instance variable anywhere other than in an initialiser or a dealloc method, you should use a suitable accessor method. - (void)viewDidLoad { id anObject = [[NSObject alloc] init]; [self setMyObject:anObject]; [anObject release]; } There is plenty of Apple sanctioned code that does not follow that recommendation, both in sample code and in documentation. Both are fine, but I would suggest something like the following, just because it avoids code duplication: - (void)viewDidUnload { [self dispose]; } It is not clear here what is the benefit of avoiding code duplication -- you're simply introducing another method that you have to keep track of. I think my explanation was clear enough. If you have lots of objects to release in both viewDidUnload and dealloc, the chances of forgetting to do so in both are non-negligible. Refactoring the common release calls into a separate method puts them all in only one place. - (void)dealloc { [self dispose]; // deallocation of stuff that was not unloaded [otherStuff release]; } This is missing: [super dealloc]; as the final statement; Indeed. That's the problem with copy/paste and doing things in Mail, rather than from real code, ie, sometimes we all make silly mistakes. Not an earth-shattering mistake to make in this list, though, since you get a warning when trying to compile without the call to super. - (void)dispose { [myObject release]; myObject = nil; } Again, you should use accessor methods rather than direct variable manipulation. Again, there is plenty of Apple sanctioned code that does not follow that recommendation. You can have -dispose be a private method of your class so it won't be accessible outside of it. One big advantage of this separation is that if/when you need to change your deallocations, you only have to do it in one place. Referring to this as deallocations is at best misleading. The goal is to relinquish ownership of any objects you're holding on to. This may or may not result in deallocation of those objects. I think everyone understood what I meant. Sometimes I mess up because of genuine confusion on my part and sometimes I mess up because of multitasking. This time it was the latter. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Yet another memory management question
On Jul 4, 2009, at 9:40 PM, WT wrote: In general, this is not recommended. If you manipulate an instance variable anywhere other than in an initialiser or a dealloc method, you should use a suitable accessor method. - (void)viewDidLoad { id anObject = [[NSObject alloc] init]; [self setMyObject:anObject]; [anObject release]; } There is plenty of Apple sanctioned code that does not follow that recommendation, both in sample code and in documentation. Where instance variables are set without using accessor methods, this should be regarded as a bug in the documentation or sample code and reported. Use of accessor methods is described plainly here: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html#//apple_ref/doc/uid/TP40004447-SW4 Indeed. That's the problem with copy/paste and doing things in Mail, rather than from real code, ie, sometimes we all make silly mistakes. Not an earth-shattering mistake to make in this list, though, since you get a warning when trying to compile without the call to super. [...] I think everyone understood what I meant. Sometimes I mess up because of genuine confusion on my part and sometimes I mess up because of multitasking. This time it was the latter. These are two fundamental errors in a reply to a basic question about the fundamentals of memory management. As I've said on a previous occasion, over the decade and a half, I've come increasingly to the opinion that many of the problems that people have with memory management are not with the Basic Rules -- if they find and read them, then people can usually understand and apply them readily enough -- but with incomplete, inaccurate, and misleading explanations of memory management given by their peers... http://www.cocoabuilder.com/archive/message/cocoa/2008/12/26/226296 mmalc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Yet another memory management question
On Jul 5, 2009, at 6:53 AM, mmalc Crawford wrote: Indeed. That's the problem with copy/paste and doing things in Mail, rather than from real code, ie, sometimes we all make silly mistakes. Not an earth-shattering mistake to make in this list, though, since you get a warning when trying to compile without the call to super. [...] I think everyone understood what I meant. Sometimes I mess up because of genuine confusion on my part and sometimes I mess up because of multitasking. This time it was the latter. These are two fundamental errors in a reply to a basic question about the fundamentals of memory management. I will remember to point that out to other people, since you often don't, when they make similar or worse silly mistakes due to typing in Mail or sending from my iPhone. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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