[iphone] UITableViewCell set cell attributes based on indexPath.row number
Hi List, If I have an UITableViewCell and want to set the cell attributes based on indexPath.row number, how could I do this? In the below example, the cells are drawn dynamically and work until the user moves the table. When the first 4 four rows are redrawn, their font changes. How do I set the first four rows to a color and not have it change? - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"Painting Row Number %d",indexPath.row); static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } [cell.textLabel setText:[tableList objectAtIndex:indexPath.row]]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; cell.textLabel.font = [UIFont systemFontOfSize:14]; cell.textLabel.numberOfLines = 2; if (indexPath.row > 3) { cell.textLabel.textColor = [UIColor redColor]; } return cell; } Thanks, Phil___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iphone] UITableViewCell set cell attributes based on indexPath.row number
Thanks Brian. That did the trick. Regards, Phil On Nov 23, 2009, at 11:55 PM, Brian Slick wrote: > The stuff outside of the if (cell == nil) block will be performed on each > cell, whether new or reused. You need to assume that the current display of > the cell is "wrong", and do what is necessary to make it right. > > In this case, if one of your red cells gets reused for rows 0-3, there is > nothing here defining what the color should be. So it will remain red. Add > an else condition that defines what the color should be for rows 0-3. > > Brian > > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
UIImageView Animation Question
Hi, I have a UIImageView that overlays a MPMoviePLayerController. When the movie plays, the view is in landscape. I want to have my overlay image to drop from the top of the movie and move down. The below code rotates the image. How do I get this effect? - (void)showOverlay:(NSTimer *)timer { NSArray *windows = [[UIApplication sharedApplication] windows]; UIImage *image = [UIImage imageNamed:@"top.png"]; UIImageView *imageView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(0.0, 0.0, image.size.width, image.size.height) ]; imageView.image = image; imageView.transform = CGAffineTransformMakeRotation(M_PI/2.0); CGFloat moveDistance = -50.0; CGContextRef context = UIGraphicsGetCurrentContext(); [UIView beginAnimations:@"moveImageDown" context:context]; [UIView setAnimationDuration:1.0]; CGAffineTransform transform = CGAffineTransformMakeTranslation(0, moveDistance); [imageView setCenter:CGPointMake(295, 480 / 2 )]; imageView.transform = transform; [UIView commitAnimations]; mpw = [windows objectAtIndex:1]; [mpw addSubview:imageView]; } Thanks Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: UIImageView Animation Question
Never mind, I figured it out. Regards, UIImage *image = [UIImage imageNamed:@"top.png"]; UIImageView *imageView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(295, 480/2, image.size.width, image.size.height) ]; imageView.image = image; imageView.transform = CGAffineTransformMakeRotation(M_PI/2.0); CGContextRef context = UIGraphicsGetCurrentContext(); [UIView beginAnimations:@"moveImageDown" context:context]; [UIView setAnimationDuration:1.0]; [imageView setCenter:CGPointMake(295, 480 / 2 )]; [UIView commitAnimations]; On Nov 25, 2009, at 6:36 PM, Philip Vallone wrote: > Hi, > > I have a UIImageView that overlays a MPMoviePLayerController. When the movie > plays, the view is in landscape. I want to have my overlay image to drop from > the top of the movie and move down. The below code rotates the image. How do > I get this effect? > > > - (void)showOverlay:(NSTimer *)timer { > > NSArray *windows = [[UIApplication sharedApplication] windows]; > > UIImage *image = [UIImage imageNamed:@"top.png"]; > UIImageView *imageView = [ [ UIImageView alloc ] > initWithFrame:CGRectMake(0.0, 0.0, image.size.width, image.size.height) ]; > imageView.image = image; > imageView.transform = CGAffineTransformMakeRotation(M_PI/2.0); > > > > CGFloat moveDistance = -50.0; > CGContextRef context = UIGraphicsGetCurrentContext(); > [UIView beginAnimations:@"moveImageDown" context:context]; > [UIView setAnimationDuration:1.0]; > CGAffineTransform transform = CGAffineTransformMakeTranslation(0, > moveDistance); > [imageView setCenter:CGPointMake(295, 480 / 2 )]; > imageView.transform = transform; > [UIView commitAnimations]; > > > > mpw = [windows objectAtIndex:1]; > [mpw addSubview:imageView]; > > } > > Thanks > > Phil > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post 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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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: UIImageView Animation Question
Hi David, Thanks for the reply. When I remove the reference to UIGraphicsGetCurrentContext() my Image doesn't drop in. Removed: CGContextRef context = UIGraphicsGetCurrentContext(); [UIView beginAnimations:@"moveImageDown" context:context]; The following code works: imageView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(295, 480/2, image.size.width, image.size.height) ]; imageView.image = image; imageView.transform = CGAffineTransformMakeRotation(M_PI/2.0); imageBottomView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(-220, 207, imageBottom.size.width, imageBottom.size.height) ]; imageBottomView.image = imageBottom; imageBottomView.transform = CGAffineTransformMakeRotation(M_PI/2.0); pos = 295; CGContextRef context = UIGraphicsGetCurrentContext(); [UIView beginAnimations:@"moveImageDown" context:context]; [UIView setAnimationDuration:2.0]; [imageView setCenter:CGPointMake(pos, 480 / 2 )]; [UIView commitAnimations]; [mpw addSubview:imageView]; Thoughts? On Nov 26, 2009, at 1:13 PM, David Duncan wrote: > On Nov 25, 2009, at 3:49 PM, Philip Vallone wrote: > >> CGContextRef context = UIGraphicsGetCurrentContext(); >> [UIView beginAnimations:@"moveImageDown" context:context]; >> [UIView setAnimationDuration:1.0]; >> [imageView setCenter:CGPointMake(295, 480 / 2 )]; >> [UIView commitAnimations]; > > > Keep in mind that the call to UIGraphicsGetCurrentContext() here is > superfluous, and likely returning NULL. You can remove it without making any > change on the behavior of your code. > -- > David Duncan > Apple DTS Animation and Printing > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
isKindofClass with NSData and NSKeyUnarchiver
Hello, I am passing different types of data to NSData (NSString, NSArray, UIImage). I am trying to find out what kind of data t is so I know how to handle the NSData when I receive it. The below code is an example of how I am trying to do this but its always returning null. What am I doing wrong? NSString *somedata = [[NSString alloc] initWithString:@"Some string"]; NSData * set = [NSKeyedArchiver archivedDataWithRootObject:[somedata dataUsingEncoding:NSASCIIStringEncoding]]; NSData * unset = [NSKeyedUnarchiver unarchiveObjectWithData:set]; NSLog(@"Class Type %@", [unset isKindOfClass:[NSKeyedUnarchiver class]]); [somedata release]; Thanks, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: isKindofClass with NSData and NSKeyUnarchiver
Ken & Alexander, Thank you so much for your help. Your explanations are extremely helpful. Best regards, Phil On May 27, 2010, at 6:36 AM, Ken Thomases wrote: > On May 27, 2010, at 4:21 AM, Philip Vallone wrote: > >> I am passing different types of data to NSData (NSString, NSArray, UIImage). >> I am trying to find out what kind of data t is so I know how to handle the >> NSData when I receive it. > > NSData is just a byte sequence. It doesn't have any knowledge about the > semantic meaning of those bytes. > > I'm not even sure what you mean by "passing different types of data to > NSData". You don't pass strings, arrays, or images to NSData. You can ask > some of those objects for data, but that's not the same thing. > > >>NSString *somedata = [[NSString alloc] initWithString:@"Some string"]; > > The above is a warning sign. I see it a lot with new Cocoa programmers. The > expression > >@"Some string" > > is already a full-fledged string object. You can send it messages and > everything. There's no reason to "turn it into a string object" or "make a > string object from it" or anything like that. Creating a new string from it, > as you've done with +alloc and -initWithString: accomplishes nothing but a > bit of waste. > > I only point it out because it indicates a weakness in your understanding of > the language and framework. > > Also, calling a string "somedata" is just going to confuse you and anybody > else reading your code. A string object is not a data object. > >>NSData * set = [NSKeyedArchiver archivedDataWithRootObject:[somedata >> dataUsingEncoding:NSASCIIStringEncoding]]; > > I don't think this is doing what you want. The expression "[somedata > dataUsingEncoding:NSASCIIStringEncoding]" asks the string to create a byte > sequence by encoding its contents into ASCII. It puts the byte sequence into > a data object and returns it to you. Once again, the data object knows > nothing about the semantics of the byte sequence. You can't query it and > ask, "were you originally a string?" It doesn't have the slightest clue. > > Then, you create another data object by key-archiving the data object with > the ASCII byte sequence. That second data object also doesn't know that it's > a keyed archive containing a data object (which happens to contain an ASCII > byte sequence of a string). > > However, it does have internal structure so that an NSKeyedUnarchiver can > rediscover that it was a data object. But that still doesn't imbue the > unarchived data object with knowledge that it originally came from a string. > > The question is, why did you ASCII-encode the string into a data object if > you were then going to archive that data object into another data object. I > think you probably want to simply archive the string, directly: > >NSData* set = [NSKeyedArchiver archivedDataWithRootObject:somedata]; > > Again, calling a data object a "set" is just confusing. > >>NSData * unset = [NSKeyedUnarchiver unarchiveObjectWithData:set]; > > With your original code, unset would now point to a data object which > contains the ASCII byte sequence obtained from the string. Still, though, > this data object has no way of knowing that its contents are ASCII-encoded > characters or that it came from a string. > >>NSLog(@"Class Type %@", [unset isKindOfClass:[NSKeyedUnarchiver class]]); > > Alexander has already pointed out the problems with this line. But, more > fundamentally, there's no amount of querying of the unarchived data object > that will reveal what it once was. It doesn't know. You'll only learn that > it is a data object. > > If you had originally archived the string object instead of a data object > obtained by asking the string to encode itself, then you would have gotten > back an equivalent string object. You could usefully ask that string object > about its class using -isKindOfClass:. > > To summarize, perhaps this does what you're looking for: > >NSString* somestring = @"Some string"; >NSData* archive = [NSKeyedArchiver archivedDataWithRootObject:somestring]; >// ... later ... >id obj = [NSKeyedUnarchiver unarchiveObjectWithData:archive]; >if ([obj isKindOfClass:[NSString class]]) >// ... use 'obj' as a string >else if ([obj isKindOfClass:[NSArray class]]) >// ... use 'obj' as an array >// ... etc. ... > > (Note that I don'
Re: isKindofClass with NSData and NSKeyUnarchiver
Hi Graham, I think Ken's response was exactly what I was looking for. The code snippet I posted was just a small example to illustrate my question and ken's was as well. > Perhaps you just need to archive a data structure at a higher level so that > what pops out when you dearchive is fully formed and ready to go, instead of > needing to be sorted by type and handled accordingly This is a relative question, which depends on how the data is coming and going. My question comes from the following situation. Suppose I have a GKSession that is passing information via Bluetooth. The sender can send any type of information (NSString, UIImage etc...). The receiver needs to know how to handle this data. If there is a better way... Then how? I appreciate the feed back and help, Phil Regards, Philip Vallone On May 27, 2010, at 8:12 PM, Graham Cox wrote: > > On 27/05/2010, at 8:36 PM, Ken Thomases wrote: > >> if ([obj isKindOfClass:[NSString class]]) >> // ... use 'obj' as a string >> else if ([obj isKindOfClass:[NSArray class]]) >> // ... use 'obj' as an array >> // ... etc. ... > > > It might also be worth pointing out that writing code structured in this way > is highly indicative of a failure of design (and I say that obviously > realising that Ken was only trying to illustrate how to discover an object's > type in the context of the example, not how best to handle the situation as a > whole). > > You need to design your code so that if its type is important you can easily > encode and decode a type indicator along with the data itself, but even then > it's a bit of a code smell. Perhaps you just need to archive a data structure > at a higher level so that what pops out when you dearchive is fully formed > and ready to go, instead of needing to be sorted by type and handled > accordingly? > > > --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/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: isKindofClass with NSData and NSKeyUnarchiver
Hi, > Wait, are you archiving and unarchiving data over a network? That’s a bad > idea unless you’re extremely careful. The problem is that a malicious peer > can send you an archive that expands into any codable object, not just the > types you were expecting; this can be exploited to do Bad Things in your > process, like crashing and possibly worse. How is it possible using GKSession to be introduced to a malicious peer.? I am creating a GKSession object and connecting via GKPeerPickerController. A hand shack is made between the the two peers. Once both peers accept the connection, the session is stored along with the peer id. This information can be checked before any information is received. Isn't this secure enough? Thanks, Phil On May 28, 2010, at 4:40 PM, Jens Alfke wrote: > >> On May 28, 2010, at 2:25 AM, Philip Vallone wrote: >>> This is a relative question, which depends on how the data is coming and >>> going. My question comes from the following situation. Suppose I have a >>> GKSession that is passing information via Bluetooth. The sender can send >>> any type of information (NSString, UIImage etc...). The receiver needs to >>> know how to handle this data. If there is a better way... Then how? > > Wait, are you archiving and unarchiving data over a network? That’s a bad > idea unless you’re extremely careful. The problem is that a malicious peer > can send you an archive that expands into any codable object, not just the > types you were expecting; this can be exploited to do Bad Things in your > process, like crashing and possibly worse. > > It would be safer and easier to send property lists instead. The property > list decoder is safe in that it will only ever output a known set of classes. > You just have to watch out that your code never takes type types of incoming > data for granted, otherwise it can throw assertion failures if it gets the > wrong data. So instead of > NSString *cmd = [message objectForKey: @“command”]; > you have to do something like > id cmd = [message objectForKey: @“command”]; > if (![cmd isKindOfClass: [NSString class]]) > return NO; // reject the message as invalid > My MYUtilities library has a macro called $castIf that makes this really easy: > NSString *cmd = $castIf(NSString, [message objectForKey: @“command”]); > It returns nil if the object isn’t of the required class. > > Yes, checking classes at runtime is often a bad-code smell. But it’s not > avoidable when working with untrusted data and untyped data structures like > plists. You have to code defensively on the assumption that any message you > receive might be corrupt or malicious. > > —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
NSNetService - send data to printer
Hi, Where can I find additional information on using NSNetService and sending data to a printer? I am able to find a printer using NSNetService, but unable to figure out how to send data. Should I use NSStream, NSSocketPort etc...? I am a bit confused. Thanks Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: NSNetService - send data to printer
Thanks Jens - always a great help. Regards, Phil On May 31, 2010, at 4:19 PM, Jens Alfke wrote: > > On May 31, 2010, at 6:50 AM, Philip Vallone wrote: > >> Where can I find additional information on using NSNetService and sending >> data to a printer? I am able to find a printer using NSNetService, but >> unable to figure out how to send data. > > Bonjour is only about service discovery. It just tells you a service’s IP > address; it doesn’t have anything to do with the connection or protocol. > >> Should I use NSStream, NSSocketPort etc...? I am a bit confused. > > NSNetService does have a convenience method -[getInputStream:outputStream:] > that will open a socket to the service’s IP address/port; so NSStream is > probably the easiest API to use. > > At that point you’ll need to use whatever data protocol the printer supports. > That’s off-topic for this list, and not something I know about; you’ll need > to do some research to find out about printing protocols. > > —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
[iPhone] Detect touches on MKMapView
Hi, Can you detect touches in a MKMapView? if so how? If not, how can I? Thanks for the help Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Code signing issues
Hi, I develop for the iphone, but If the process is the same for a Mac App, you should have 2 certificates in Key chain 1. Mac Developer 2. Mac Distribution On Oct 17, 2011, at 7:34 PM, Gideon King wrote: > 1. When creating the certificates, 3 certs are created and added to the > keychain - should I be able to see all three of them in Xcode? If so, what do > I need to do to get them to show up there? > > 2. When I do a build using my "Mac Developer" cert, it doesn't give any > errors when signing, but the Store seems to think that the app is not signed. > What do I do about this? > > 3. When I sign with my "3rd Party Mac Developer Application", I get the > message about it not being a test user account, and to create an account in > the sandbox. Is this something I need to do in the App store, in my > development settings, a different Apple ID, or on my computer? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: TBXML question
Hi Eric, Have you considered using Libxml and xpath? Take a look at http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html. Phil On Jan 13, 2012, at 9:23 AM, Eric E. Dolecki wrote: > I have XML like this: > > > > > > > > > > I am trying pull out the name and then each of the playlists. I need help > with my while loop (to get all the playlists) - I've bolded that bit. > > - (void)parseThatXML:(TBXMLElement *)element { > >do { > >if(element -> firstChild) > >[self parseThatXML:element -> firstChild]; > >if([[TBXML elementName:element] isEqualToString:@"user"]){ > >NSString *userName = [TBXML valueOfAttributeNamed:@"name" > forElement:element]; > >NSLog(@"user: %@", userName); > > * TBXMLElement *playlist = [TBXML childElementNamed:@"playlist" > parentElement:element];* > > *while (playlist != nil) {* > > *NSLog(@"%@", [TBXML valueOfAttributeNamed:@"name" > forElement:playlist]); //infinite loop. how loop through all the playlists > for the user?* > > *}* > >//TBXMLElement *playlist = [TBXML childElementNamed:@"playlist" > parentElement:element]; > >//NSLog(@"%@", [TBXML valueOfAttributeNamed:@"name" > forElement:playlist]); > >} > >} while ((element = element -> nextSibling)); > > } > > > > > > > Google Voice: (508) 656-0622 > Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki > http://blog.ericd.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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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
[iOS] NSUserDefaults best practices
Hi, After some reading I understand that when creating a Settings Bundle for by iOS app, that I need to explicitly set the defaults. I was wondering if anyone had a preference for where you are setting the defaults. For example in the App Delegate. I decided to use a singleton to set my defaults settings. When the application is launched, I initiate the singleton from the didFinishLaunchingWithOptions in my App Delegate. What are your thoughts on doing this? Thanks, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iOS] NSUserDefaults best practices
Thanks Matt and thanks to all the others that replied. Regards, Phil On Feb 5, 2011, at 5:46 PM, Matt Neuburg wrote: > On Sat, 05 Feb 2011 07:33:08 -0500, Philip Vallone > said: >> Hi, >> >> After some reading I understand that when creating a Settings Bundle for by >> iOS app, that I need to explicitly set the defaults. > > You don't *have* to; the settings bundle itself specifies your default > defaults. It must, since otherwise if the user summons your bundle through > the Settings app, how will the Settings app know what default values to give > your defaults? The Settings app will register those values into the shared > user defaults for you. The only reason you need to set default defaults in > the app itself is in case the Settings app hasn't run. But, of course, it > might not, so it's good practice. > >> I decided to use a singleton to set my defaults settings. When the >> application is launched, I initiate the singleton from the >> didFinishLaunchingWithOptions in my App Delegate. > > NSUserDefaults' standardUserDefaults *is* a singleton. Just call > registerDefaults: in didFinishLaunching... and you're done. (There is no > need, in iOS, to do it any earlier, as with +initialize, because there are no > bindings in iOS.) m. > > -- > matt neuburg, phd = m...@tidbits.com, <http://www.apeth.net/matt/> > A fool + a tool + an autorelease pool = cool! > AppleScript: the Definitive Guide - Second Edition! > http://www.apeth.net/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
HTML Writer class
Hi list, Is there a Cocoa Touch class for creating HTML documents? For example, in C# there is the HTMLDoument class. I searched the reference docs, but came up empty. Regards, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: HTML Writer class
Thanks Mike! On Mar 21, 2011, at 10:45 AM, Mike Abdullah wrote: > https://github.com/karelia/KSHTMLWriter > Standard BSD license ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Remove KVO for MKAnnotationViews
Hi, I am in need of some help. I have a MKMapView object, which allows the user to add, move and delete MKAnnotationViews. When an Annotation is added to the map, I use KVO to track if the Annotation was moved or selected: for (MKAnnotationView *anAnnotationView in views) { [anAnnotationView addObserver:self forKeyPath:@"selected" options:NSKeyValueObservingOptionNew context:@"MapAnnontationSelected"]; } Here is how I add the annotation: - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id ) annotation{ MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"]; annView.animatesDrop= YES; annView.canShowCallout = YES; annView.draggable = YES; UIImage *image = [UIImage imageNamed:@"gps_add.png"]; UIImageView *imgView = [[[UIImageView alloc] initWithImage:image] autorelease]; annView.leftCalloutAccessoryView = imgView; annView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; annView.pinColor = MKPinAnnotationColorGreen; return [annView autorelease]; } The problem occurs when I delete the Annotation. Since the MKPinAnnotationView is set to auto release, the object is deallocated with the observer still attached. "An instance 0xb323890 of class MKPinAnnotationView was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:" I tried to remove the observer when the pin gets deleted, but that still gives the error: for (id annotation in mapView.annotations) { [[mapView viewForAnnotation:annotation] removeObserver:self forKeyPath:@"selected"]; } Any help would be greatly appreciated. Thx. Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Show UIActivityIndicatorView asynchronously
Hi, I have a UIViewController that can take a few seconds to load. The view searches an XML file and eventually displays the resuts. I want to show a UIActivityIndicatorView while the view loads. Unfortunately they are on the same thread. How can I get the UIActivityIndicatorView to display befiore the view loads? With the below code, the UI freezes up (indicator never shows) until the search is done. [self.activityIndicator startAnimating]; TitleSearchResultsViewController *controller = [[TitleSearchResultsViewController alloc] initWithNibName:@"TitleSearchResultsViewController" bundle:nil]; [controller setTitle:@"Search Results"]; Thanks, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Show UIActivityIndicatorView asynchronously
Thanks. Works like a charm. Regards, Phil Sent from Phil's iPhone On Apr 28, 2011, at 1:38 PM, Matt Neuburg wrote: > On Thu, 28 Apr 2011 06:26:17 -0400, Philip Vallone > said: >> Hi, >> >> I have a UIViewController that can take a few seconds to load. The view >> searches an XML file and eventually displays the resuts. I want to show a >> UIActivityIndicatorView while the view loads. Unfortunately they are on the >> same thread. How can I get the UIActivityIndicatorView to display befiore >> the view loads? With the below code, the UI freezes up (indicator never >> shows) until the search is done. >> >> [self.activityIndicator startAnimating]; >> >> TitleSearchResultsViewController *controller = >> [[TitleSearchResultsViewController alloc] >> initWithNibName:@"TitleSearchResultsViewController" bundle:nil]; >> [controller setTitle:@"Search Results"]; > > Use delayed performance. Here's sample code from one of my own apps: > > - (void)tableView:(UITableView *)tableView > didSelectRowAtIndexPath:(NSIndexPath *)indexPath { >[act startAnimating]; >// jump out using delayed performance, to give us a chance to start > animating the UIActivityIndicatorView >[self performSelector:@selector(showItemsForRow:) withObject:indexPath > afterDelay:0.1]; > } > > And then showItemsForRow inits the view controller and loads its view in the > usual way. m. > > -- > matt neuburg, phd = m...@tidbits.com, <http://www.apeth.net/matt/> > A fool + a tool + an autorelease pool = cool! > Programming iOS 4! > http://www.apeth.net/matt/default.html#iosbook ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Subclassing UItextview
Hi, I am taking a shot at creating a Twitter App. I was wondering if its possible to Subclass UItextview to detect hashes and respond to them. For example: "This is a tweet #iamtrending" I've seen this done in other Apps, but not sure where to start. Thanks for the help. Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Subclassing UItextview
Thanks Fritz. This is a great suggestion. On Jun 4, 2011, at 10:22 AM, Fritz Anderson wrote: > On 4 Jun 2011, at 8:32 AM, Philip Vallone wrote: > >> I am taking a shot at creating a Twitter App. I was wondering if its >> possible to Subclass UItextview to detect hashes and respond to them. For >> example: >> >> "This is a tweet #iamtrending" >> >> I've seen this done in other Apps, but not sure where to start. > > UITextView does not render multiple styles, nor offer link-like behavior. To > subclass, you'd have to rip out most of the implementation. If you want those > things, use UIWebView, which is what the other apps (at least the ones > written by sane people) are doing. Convert the hash-tags to content, with > a CSS class for special rendering, and your own URL scheme for capturing your > special action for touches. > > — 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: Subclassing UItextview
Thank you Conrad for your feedback. > Finally, depending on how many webviews you use, you might massacre the > performance of UITableView scrolling. Luckily, I am not using UITableView. I have implement the UIWebView and it works well. I am not sure if the issues you mentioned are still issues, but in my situation, using the UIWebView allows for a lot of control over the look and feel using javascript and HTML. Thanks again. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Cast NSNumber to int
H, I want to cast a NSNumber to int. When I execute the below code, my result should be 1, not 68213232. What am I doing wrong? Code: NSNumber *setCurrentCount = [NSNumber numberWithInt: 1]; NSLog(@"Test NSNumber cast to int: %i", setCurrentCount); Output: Test NSNumber cast to int: 68213232 Thanks, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Cast NSNumber to int
Thanks for the quick response. Works like a charm! On Nov 28, 2009, at 6:26 AM, Andrew Farmer wrote: > On 28 Nov 2009, at 03:20, Philip Vallone wrote: >> I want to cast a NSNumber to int. When I execute the below code, my result >> should be 1, not 68213232. What am I doing wrong? > > You are trying to cast a pointer to an integer and expecting meaningful > results. Don't. > > If you want to get the numeric value of a NSNumber object, use its intValue > (or floatValue, longValue, etc.) method. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: MacResearch Tutorial on beginning a Cocoa/iPhone app.
This post is very misleading. The tutorial is called "Using VVI for Graphing on iPhone" however there is no graphing. The graph is pulled in from the website and viewed through the UIWebView. Just my thoughts... On Dec 3, 2009, at 12:09 PM, lbland wrote: > hi- > > Occasionally I see a trouble-getting-started post on this list. There is a > great Cocoa/Xcode/iPhone tutorial on MacResearch: > > Using VVI for Graphing on iPhone > http://www.macresearch.org/using-vvi-graphing-iphone > > Explaining in precise detail how to make a simple iPhone app. I may be a bit > partial to the writing style though :-) > > thanks!- > > -lance > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post 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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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
[iphone] Libxml2 with a wrapper to NSArray
Hi, I hope I am posting this to the write list. I am trying to parse an xml file with libxml2 and xpath. I am still learning objective c and Cocoa. I found this very useful wrapper for libxml: http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html However, I am not sure how to call this : NSArray *PerformHTMLXPathQuery(NSData *document, NSString *query) Here is my code: NSString *filePath = [[NSBundle mainBundle] pathForResource:@"manifest" ofType:@"xml"]; NSData* xmlData = [filePath dataUsingEncoding:NSUTF8StringEncoding]; NSArray *resultNodes = [NSArray array]; resultNodes = PerformXPathQuery(xmlData, "//mynode"); Here is my error: warning: implicit declaration of function 'PerformXPathQuery' Thanks for the help. Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iphone] Libxml2 with a wrapper to NSArray
Hi Thanks for the help. I did not receive any message from Sean, but your comments lead me in the right direction. First I changed xmlData to: NSData * xmlData = [NSData dataWithContentsOfFile: filePath]; Next I had a syntax error when declaring my NSArray and like you said it was pointing to an empty array: NSArray* result = [NSArray arrayWithArray:PerformXMLXPathQuery(xmlData, @"//mynode")]; Final solution: NSString *filePath = [[NSBundle mainBundle] pathForResource:@"manifest" ofType:@"xml"]; NSData * xmlData = [NSData dataWithContentsOfFile: filePath]; NSArray* result = [NSArray arrayWithArray:PerformXMLXPathQuery(xmlData, @"//mynode")]; As for your last point about learning C, I have picked up 2 books on the subject and have been learning. Thanks again for the help Phil On Dec 3, 2009, at 10:34 PM, Fritz Anderson wrote: > On 3 Dec 2009, at 5:40 PM, Philip Vallone wrote: > >> NSString *filePath = [[NSBundle mainBundle] pathForResource:@"manifest" >> ofType:@"xml"]; >> NSData* xmlData = [filePath dataUsingEncoding:NSUTF8StringEncoding]; > > Separate from Sean's help, sending dataUsingEncoding: to an NSString gets you > an NSData that wraps the binary representation of the characters of the > string itself. You want something like > > NSData * xmlData = [NSData dataWithContentsOfFile: filePath]; > > Also: >> NSArray *resultNodes = [NSArray array]; > > This points the variable resultNodes at an empty NSArray, which you will not > be able to change. > >> warning: implicit declaration of function 'PerformXPathQuery' > > This indicates that you use of PerformXPathQuery was the first time the > compiler has ever seen that function. It is universal practice to declare > functions in advance, usually in a header (.h) file imported into the source > file. It helps the compiler generate correct code and warn you about > potential errors. > > This last point is kind of basic to C. If you're not used to C, you shouldn't > be starting with Objective-C, Cocoa, and libxml. Take a couple of weeks, back > off, and learn C and its standard libraries first. > > — 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: MacResearch Tutorial on beginning a Cocoa/iPhone app.
Thanks Brian, This looks very useful. Regards, Phil On Dec 3, 2009, at 5:25 PM, Brian Dittmer wrote: > If you need graphing/charting on either iPhone or OSX then checkout > CorePlot, it's a rather impressive and mature library for generating > graphs and charts. > > http://code.google.com/p/core-plot/ > > Cheers, > Brian > > > On Thu, Dec 3, 2009 at 4:38 PM, Karolis Ramanauskas > wrote: >> Agreed, no network connection no graph! ;) What if I need to update my graph >> live? >> >> On Thu, Dec 3, 2009 at 2:48 PM, Philip Vallone >> wrote: >> >>> This post is very misleading. The tutorial is called "Using VVI for >>> Graphing on iPhone" however there is no graphing. The graph is pulled in >>> from the website and viewed through the UIWebView. >>> >>> Just my thoughts... >>> >>> >>> >>> >>> On Dec 3, 2009, at 12:09 PM, lbland wrote: >>> >>>> hi- >>>> >>>> Occasionally I see a trouble-getting-started post on this list. There is >>> a great Cocoa/Xcode/iPhone tutorial on MacResearch: >>>> >>>> Using VVI for Graphing on iPhone >>>> http://www.macresearch.org/using-vvi-graphing-iphone >>>> >>>> Explaining in precise detail how to make a simple iPhone app. I may be a >>> bit partial to the writing style though :-) >>>> >>>> thanks!- >>>> >>>> -lance >>>> >>>> >>>> ___ >>>> >>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >>>> >>>> Please do not post 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/philip.vallone%40verizon.net >>>> >>>> This email sent to philip.vall...@verizon.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/karolisr%40gmail.com >>> >>> This email sent to karol...@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/brian.t.dittmer%40gmail.com >> >> This email sent to brian.t.ditt...@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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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: [iphone] Libxml2 with a wrapper to NSArray
Good point - Thanks On Dec 4, 2009, at 1:32 PM, Alexander Spohr wrote: > > Am 04.12.2009 um 10:09 schrieb Philip Vallone: > >> Next I had a syntax error when declaring my NSArray and like you said it was >> pointing to an empty array: >> >> NSArray* result = [NSArray arrayWithArray:PerformXMLXPathQuery(xmlData, >> @"//mynode")]; > > Why are you putting the contents of the array you got into another array? > Just keep the array you get: > NSArray* result = PerformXMLXPathQuery(xmlData, @"//mynode"); > > atze > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
[iPhone] Add a UIProgressView as subview to a navigationController
Hi list, Is it possible to add a UIProgressView as subview to a navigationController? I am trying the below example, but it does not show up. I suspect my UIProgressView is out of view... UIProgressView *progbar = [[UIProgressView alloc] initWithFrame: CGRectMake(50.0f, 70.0f, 220.0f, 90.0f)]; [progbar setProgressViewStyle:UIBarButtonItemStylePlain ]; [progbar setCenter:CGPointMake(160, 20 )]; [progbar setProgress:0.10]; [self.navigationController.navigationBar.topItem setTitleView:progbar]; Thanks for the help. Phil___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
[iPhone] Animate tableView reloadData
Hi List, I have a table that gets reloaded when a user presses a button. Is it possible to animate reloadData and if so can you point me in the right direction? Thanks Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone] Animate tableView reloadData
Thanks Luck for the guidance. Phil On Dec 11, 2009, at 9:49 AM, Luke the Hiesterman wrote: > There's a set of methods in UITableView for animated table updates. All the > insert/delete/road calls should be within a beginUpdates/endUpdates block. > > - (void)beginUpdates; // allow multiple insert/delete of rows and sections > to be animated simultaneously. Nestable > - (void)endUpdates; // only call insert/delete/reload calls inside an > update block. otherwise things like row count, etc. may be invalid. > > - (void)insertSections:(NSIndexSet *)sections > withRowAnimation:(UITableViewRowAnimation)animation; > - (void)deleteSections:(NSIndexSet *)sections > withRowAnimation:(UITableViewRowAnimation)animation; > - (void)reloadSections:(NSIndexSet *)sections > withRowAnimation:(UITableViewRowAnimation)animation > __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); > > - (void)insertRowsAtIndexPaths:(NSArray *)indexPaths > withRowAnimation:(UITableViewRowAnimation)animation; > - (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths > withRowAnimation:(UITableViewRowAnimation)animation; > - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths > withRowAnimation:(UITableViewRowAnimation)animation > __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); > > Luke > > On Dec 11, 2009, at 3:53 AM, Philip Vallone wrote: > >> >> Hi List, >> >> I have a table that gets reloaded when a user presses a button. Is it >> possible to animate reloadData and if so can you point me in the right >> direction? >> >> Thanks >> >> Phil >> >> ___ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post 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/luketheh%40apple.com >> >> This email sent to luket...@apple.com > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSXMLParser question about duplicate nodes
Hi. I would recommend LibXML. This post is excellent and the the author created an Objective C Wrapper. http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html Regards, On Jan 6, 2010, at 2:28 PM, Eric E. Dolecki wrote: > This is what I am doing now that feels like a hack (I only ever get a 2 day > forecast, the one for today is the first): > > if( [elementName isEqualToString:@"yweather:forecast"]){ > > NSString *tmpDay = [attributeDict valueForKey:@"day"]; > > NSDate *now = [NSDate date]; > > NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; > > [formatter setDateFormat:@"ccc"]; > > NSString *dateString = [formatter stringFromDate:now]; > > if( [dateString isEqualToString:tmpDay]){ > > //today > > } else { > > //tomorrow > > } > > } > > On Wed, Jan 6, 2010 at 1:34 PM, Jeremy Pereira wrote: > >> >> On 6 Jan 2010, at 18:13, Eric E. Dolecki wrote: >> >> Well okay yes... same element name but I need to tell them apart. >> >> >> The day attribute has a different value in each case though. Just pull out >> the the object with the key @"day" from the attribute dictionary. >> >> >> On Wed, Jan 6, 2010 at 1:07 PM, Jeremy Pereira wrote: >> >>> >>> On 6 Jan 2010, at 16:22, Eric E. Dolecki wrote: >>> I am fetching weather data & in my results I am getting today and >>> tomorrow's forecasts. However they have the same node: How can I get at those separately in my didStartElement? Is there a way >>> to turn that into an array or something? >>> >>> No they don't have the same node. They are two nodes with the same >>> element name. If both appear in your XML they will each result in a call >>> to the parser:didStartElement:... method. >>> >>> ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/adc%40jeremyp.net This email sent to a...@jeremyp.net >>> >>> >> >> >> -- >> http://ericd.net >> Interactive design and development >> >> >> > > > -- > http://ericd.net > Interactive design and development > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post 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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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: Table object not selected on launch
Hi, I have a similar app that requires the same affect. What I did was create a boolean or valve that indicates if the cell can be selected. In my iphone app, this can be done in the didSelectRowAtIndexPath Method. Something like this: if (indexPath.row > getCurrent) { return; } In this example gertCurrent is returned from a sqlite query, if the indexPath.row is greater then the sqlite query, then you can dump out of the method. Regards, Phil On Jan 12, 2010, at 2:28 AM, Jenny M wrote: > When my application launches, I have a custom BackgroundView that takes the > role of first responder. Within the main window, I have a NSScrollView that > contains core data objects in an NSArrayController. I want the objects to > load in the table on launch, but I don't want any objects to be *selected* > upon launch. I've looked in IB and the docs and can't figure out which > attribute to set to make this possible. Thoughts? > > 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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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
[iphone] Load time and Nav View Controller.
Hi, I have a Navigation Based iPhone Application. If I am going from one nav view to another it may take about 3 seconds to view the next view. This is because the the view loads a large xml file into a NSArray and then must render it. My question is, how can I display a UIActivityIndicatorView while the view is being loaded. if I add it right before the my method to load the second view, it doesn't display until after the view loaded. // Add UIActiviatyIndicatorView here PartViewController *thePartPage = [[PartViewController alloc] initWithNibName:@"PartViewController" bundle:nil]; [thePartPage setTitle:rowValue]; [self.navigationController pushViewController:thePartPage animated:YES]; Thanks, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iphone] Load time and Nav View Controller.
Hmmm Figured it out. I needed to run the activity indicator on another thread [NSThread detachNewThreadSelector: @selector(showIndicator) toTarget:self withObject:nil]; Thanks, On Jan 16, 2010, at 3:46 PM, Philip Vallone wrote: > Hi, > > I have a Navigation Based iPhone Application. If I am going from one nav view > to another it may take about 3 seconds to view the next view. This is because > the the view loads a large xml file into a NSArray and then must render it. > My question is, how can I display a UIActivityIndicatorView while the view is > being loaded. if I add it right before the my method to load the second view, > it doesn't display until after the view loaded. > > > // Add UIActiviatyIndicatorView here > > PartViewController *thePartPage = [[PartViewController alloc] > initWithNibName:@"PartViewController" bundle:nil]; > [thePartPage setTitle:rowValue]; > [self.navigationController pushViewController:thePartPage animated:YES]; > > Thanks, > > Phil > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post 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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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: [iphone] Load time and Nav View Controller.
Thanks Dave. Great advise. I've made the change. Regards. Phil On Jan 16, 2010, at 4:02 PM, Dave DeLong wrote: > Ack. You should never do UI stuff on secondary threads. What you should be > doing is loading your large XML file on the second thread, and then once that > thread is done, make the activity indicator disappear (on the main thread). > > Dave > > On Jan 16, 2010, at 2:00 PM, Philip Vallone wrote: > >> Hmmm Figured it out. I needed to run the activity indicator on another >> thread >> >> [NSThread detachNewThreadSelector: @selector(showIndicator) toTarget:self >> withObject:nil]; > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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
[iphone] Release Navigation View Controller Question
Hi, I have Navigation based application. When I switch from one view to the next I use the following code. In the below code, is it ok to release "browseviewController"? BrowseViewController *browseviewController = [[BrowseViewController alloc] initWithNibName:@"BrowseViewController" bundle:nil]; [browseviewController setTitle:@"Browse By Title"]; [self.navigationController pushViewController:browseviewController animated:YES]; // ok to release? [browseviewController release]; Thanks, Phil___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iphone] Release Navigation View Controller Question
Thanks Tom. Great explanation! On Jan 17, 2010, at 6:05 AM, Tom Davie wrote: > Yes, that code is 100% fine. > > Here's the logic from purely your point of view. > > You allocate browserviewController and in doing so take ownership. > You do some stuff with browserviewController. > You are finished with browserviewController, and don't want to do anything > else with it, so you resign ownership. > > From a more global perspective, the navigationController becomes interested > in browserviewController when you ask it to push it, and it too takes > ownership, so when *you* release, the navigationController still has a handle > on the controller, and keeps hold of it until it decides it's done with it. > > Bob > > On Sun, Jan 17, 2010 at 10:30 AM, Philip Vallone > wrote: > > Hi, > > I have Navigation based application. When I switch from one view to the next > I use the following code. In the below code, is it ok to release > "browseviewController"? > > > BrowseViewController *browseviewController = [[BrowseViewController alloc] > initWithNibName:@"BrowseViewController" bundle:nil]; > [browseviewController setTitle:@"Browse By Title"]; > [self.navigationController pushViewController:browseviewController > animated:YES]; > // ok to release? > [browseviewController release]; > > > Thanks, > > Phil___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post 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/tom.davie%40gmail.com > > This email sent to tom.da...@gmail.com > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iphone] Release Navigation View Controller Question
Hi this is a follow up question on memory management. In my class BrowseViewController, I have a UITableView and 2 NSMutableArrays. @interface BrowseViewController : UIViewController { IBOutlet UITableView *tableView; NSMutableArray *tableList; NSMutableArray *cfrTitleList; } @property(nonatomic, retain) UITableView *tableView; @end Now the BrowseViewController has a few "child" Navigational controllers. This allows the user to drill down. My question is, in the BrowseViewController.m dealloc method, if I release the two NSMutableArrays, I receive the error “EXC_BAD_ACCESS”. If I don't release the NSMutableArrays, does this mean the navigationController takes ownership of the NSMutableArrays? Thanks for all the help. Phil On Jan 17, 2010, at 6:44 AM, Philip Vallone wrote: > Thanks Tom. Great explanation! > > > On Jan 17, 2010, at 6:05 AM, Tom Davie wrote: > >> Yes, that code is 100% fine. >> >> Here's the logic from purely your point of view. >> >> You allocate browserviewController and in doing so take ownership. >> You do some stuff with browserviewController. >> You are finished with browserviewController, and don't want to do anything >> else with it, so you resign ownership. >> >> From a more global perspective, the navigationController becomes interested >> in browserviewController when you ask it to push it, and it too takes >> ownership, so when *you* release, the navigationController still has a >> handle on the controller, and keeps hold of it until it decides it's done >> with it. >> >> Bob >> >> On Sun, Jan 17, 2010 at 10:30 AM, Philip Vallone >> wrote: >> >> Hi, >> >> I have Navigation based application. When I switch from one view to the next >> I use the following code. In the below code, is it ok to release >> "browseviewController"? >> >> >> BrowseViewController *browseviewController = [[BrowseViewController alloc] >> initWithNibName:@"BrowseViewController" bundle:nil]; >> [browseviewController setTitle:@"Browse By Title"]; >> [self.navigationController pushViewController:browseviewController >> animated:YES]; >> // ok to release? >> [browseviewController release]; >> >> >> Thanks, >> >> Phil___ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post 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/tom.davie%40gmail.com >> >> This email sent to tom.da...@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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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: [iphone] Release Navigation View Controller Question
Thanks, You are correct. I needed to retain it @property (nonatomic, retain) NSMutableArray *tableList; @property (nonatomic, retain) NSMutableArray *cfrTitleList; Then dealloc it: - (void)dealloc { [tableList release]; [cfrTitleList release]; [super dealloc]; } I spent sometime yesterday reading on memory management and sure to have more questions... Thanks again, Phil On Jan 18, 2010, at 5:58 PM, Alexander Spohr wrote: > > Am 18.01.2010 um 14:40 schrieb Philip Vallone: > >> Hi this is a follow up question on memory management. In my class >> BrowseViewController, I have a UITableView and 2 NSMutableArrays. >> >> @interface BrowseViewController : UIViewController { >> IBOutlet UITableView *tableView; >> NSMutableArray *tableList; >> NSMutableArray *cfrTitleList; >> } >> @property(nonatomic, retain) UITableView *tableView; >> >> @end >> >> Now the BrowseViewController has a few "child" Navigational controllers. >> This allows the user to drill down. My question is, in the >> BrowseViewController.m dealloc method, if I release the two NSMutableArrays, >> I receive the error “EXC_BAD_ACCESS”. > > Then you forgot to retain them when you should. > Show code where they are assigned if you can’t fix it. > >> If I don't release the NSMutableArrays, does this mean the >> navigationController takes ownership of the NSMutableArrays? > > No, it does not even know they exist. How should it? > > atze > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Proper Memory Management
I am I trying to learn proper memory management and have question: In the following example, which objects am I responsible to release? - (void) viewDidLoad{ NSString *tempStr = nil; NSString *filepath = [[NSBundle mainBundle] pathForResource:@"filename" ofType:@"xml"]; NSData *xmlData = [NSData dataWithContentsOfFile:filepath]; NSMutableString *xqueryStr = [NSMutableString stringWithFormat:@"/data/title/@number"]; NSArray *resultNodes = PerformXMLXPathQuery(xmlData, xqueryStr); NSEnumerator *e = [resultNodes objectEnumerator]; id object; while (object = [e nextObject]) { for (NSString *key in object){ tempStr = [[object objectForKey:key] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; if ([tempStr isEqualToString:@"number"] ) { }else { // do something here } } } } Thanks, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Proper Memory Management
Awesome - Thanks! On Jan 19, 2010, at 3:52 PM, Dave DeLong wrote: > None of them. > > According to the memory management rules, you're only responsible for objects > you create via an "alloc", "new", or "copy" method, which none of these are. > All of these objects are autoreleased. > > Dave > > On Jan 19, 2010, at 1:50 PM, Philip Vallone wrote: > >> >> I am I trying to learn proper memory management and have question: In the >> following example, which objects am I responsible to release? >> >> >> - (void) viewDidLoad{ >> >> NSString *tempStr = nil; >> NSString *filepath = [[NSBundle mainBundle] pathForResource:@"filename" >> ofType:@"xml"]; >> >> NSData *xmlData = [NSData dataWithContentsOfFile:filepath]; >> >> NSMutableString *xqueryStr = [NSMutableString >> stringWithFormat:@"/data/title/@number"]; >> >> NSArray *resultNodes = PerformXMLXPathQuery(xmlData, xqueryStr); >> >> NSEnumerator *e = [resultNodes objectEnumerator]; >> >> id object; >> >> while (object = [e nextObject]) { >> >> for (NSString *key in object){ >> >> tempStr = [[object objectForKey:key] >> stringByTrimmingCharactersInSet:[NSCharacterSet >> whitespaceAndNewlineCharacterSet]]; >> >> if ([tempStr isEqualToString:@"number"] ) { >> >> }else { >> >> // do something here >> >> } >> } >> >> } >> >> } >> >> Thanks, >> >> Phil >> >> >> >> ___ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post 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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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: Proper Memory Management
Thanks.. Good question. The method in question "PerformXMLXPathQuery" is a wrapper that was obtained: http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html NSArray *PerformXMLXPathQuery(NSData *document, NSString *query) { xmlDocPtr doc; /* Load XML document */ doc = xmlReadMemory([document bytes], [document length], "", NULL, XML_PARSE_RECOVER); if (doc == NULL) { NSLog(@"Unable to parse."); return nil; } NSArray *result = PerformXPathQuery(doc, query); xmlFreeDoc(doc); return result; } How can I tell who has ownership of the Array? Thanks! On Jan 19, 2010, at 3:56 PM, Dave Carrigan wrote: > > On Jan 19, 2010, at 12:52 PM, Dave DeLong wrote: > >> None of them. >> >> According to the memory management rules, you're only responsible for >> objects you create via an "alloc", "new", or "copy" method, which none of >> these are. All of these objects are autoreleased. > > Unless PerformXMLXPathQuery returns an object that you own. But if it does > that, it should have been given a better name that has the word alloc, new or > copy in it. > > -- > Dave Carrigan > d...@rudedog.org > Seattle, WA, USA > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post 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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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: Proper Memory Management
Thanks Jack, Considering the original example: - (void) viewDidLoad{ NSString *tempStr = nil; NSString *filepath = [[NSBundle mainBundle] pathForResource:@"filename" ofType:@"xml"]; NSData *xmlData = [NSData dataWithContentsOfFile:filepath]; NSMutableString *xqueryStr = [NSMutableString stringWithFormat:@"/data/title/@number"]; NSArray *resultNodes = PerformXMLXPathQuery(xmlData, xqueryStr); NSEnumerator *e = [resultNodes objectEnumerator]; id object; while (object = [e nextObject]) { for (NSString *key in object){ tempStr = [[object objectForKey:key] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; if ([tempStr isEqualToString:@"number"] ) { }else { // do something here } } } } if I use "resultNodes" within the scope of viewDidLoad, then there is no need to retain "resultNodes"? Thanks for all the help, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
[iPhone] Adding a UIView to current view
Hi List, I have a UIView (BubbleView) that I want to add to my current view (a loading splash screen). I have synthesized "myBubble". I have a method that when called is suppose to add the view, but the view doesn't show up. I am not sure what I am missing ChapterViewController.h @interface ChapterViewController : UIViewController { BubbleView *myBubble; } @property(nonatomic, retain )BubbleView *myBubble; ChapterViewController.m - (void) showLoading{ self.myBubble.frame = CGRectMake(30, 100, 260, 220); self.myBubble.backgroundColor = [UIColor clearColor]; CGRect contentRect = CGRectMake(35, 30, 240, 40); UILabel *textView = [[UILabel alloc] initWithFrame:contentRect]; textView.text = @"Loading ..."; textView.numberOfLines = 1; textView.textColor = [UIColor whiteColor]; textView.backgroundColor = [UIColor clearColor]; textView.font = [UIFont systemFontOfSize:22]; [self.myBubble addSubview:textView]; UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(110, 100, 50, 50)]; activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge; [activityIndicator startAnimating]; [activityIndicator hidesWhenStopped]; [self.myBubble addSubview:activityIndicator]; [self.view addSubview:myBubble]; [activityIndicator release]; [textView release]; } Thanks for the help, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone] Adding a UIView to current view
Thank you Luke, That was it. Thanks, Phil On Jan 21, 2010, at 6:38 PM, Luke the Hiesterman wrote: > Standard first question: did you verify that myBubble is non-nil? > > Another note: it's weird that you do [self.view addSubview:myBubble] when > through the rest of the method you always use self.myBubble. You should stick > to using your property. > > Luke > > On Jan 21, 2010, at 3:33 PM, Philip Vallone wrote: > >> >> Hi List, >> >> I have a UIView (BubbleView) that I want to add to my current view (a >> loading splash screen). I have synthesized "myBubble". I have a method >> that when called is suppose to add the view, but the view doesn't show up. >> >> I am not sure what I am missing >> >> ChapterViewController.h >> >> @interface ChapterViewController : UIViewController { >> >> BubbleView *myBubble; >> } >> >> @property(nonatomic, retain )BubbleView *myBubble; >> >> >> ChapterViewController.m >> >> - (void) showLoading{ >> >> >> self.myBubble.frame = CGRectMake(30, 100, 260, 220); >> self.myBubble.backgroundColor = [UIColor clearColor]; >> >> CGRect contentRect = CGRectMake(35, 30, 240, 40); >> >> UILabel *textView = [[UILabel alloc] initWithFrame:contentRect]; >> >> textView.text = @"Loading ..."; >> textView.numberOfLines = 1; >> textView.textColor = [UIColor whiteColor]; >> textView.backgroundColor = [UIColor clearColor]; >> textView.font = [UIFont systemFontOfSize:22]; >> >> [self.myBubble addSubview:textView]; >> >> UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView >> alloc] initWithFrame:CGRectMake(110, 100, 50, 50)]; >> activityIndicator.activityIndicatorViewStyle = >> UIActivityIndicatorViewStyleWhiteLarge; >> [activityIndicator startAnimating]; >> [activityIndicator hidesWhenStopped]; >> >> [self.myBubble addSubview:activityIndicator]; >> >> [self.view addSubview:myBubble]; >> >> [activityIndicator release]; >> [textView release]; >> >> >> } >> >> Thanks for the help, >> >> Phil >> >> >> ___ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post 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/luketheh%40apple.com >> >> This email sent to luket...@apple.com > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Synthesize NSMutableString retain count question
Hi List, This is probably a very elementary question. I have a NSMutableString that I Synthesize. When I assigned a value to it: currentSection = @"Some value"; The retain count goes to 1 However if I assign a value with [currentSection setString:@"Some value"]; The retain count is still zero. Can someone explain the difference? Thanks, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Synthesize NSMutableString retain count question
Thanks.. perfect explanation. On Feb 3, 2010, at 12:37 PM, Jens Alfke wrote: > > On Feb 3, 2010, at 3:55 AM, Philip Vallone wrote: > >> currentSection = @"Some value"; >> The retain count goes to 1 > > This assigns a new value to the pointer variable 'currentSection'. It now > points to the immutable string literal @"Some value". > >> However if I assign a value with >> [currentSection setString:@"Some value"]; >> The retain count is still zero. > > This tells the mutable string object that 'currentSection' currently points > to, to replace its contents with the characters in the string @"Some value". > > If you find the retain count is zero after this, it's probably because the > value of 'currentSection' is nil, i.e. it doesn't point to any object. In > that case the -setString: message is a no-op since messages to nil are > ignored, and -retainCount will return zero because messages to nil always > return 0/nil. > > In general, it sounds as though you're unclear on the distinction between an > object and a pointer to an object. It's the same as structs vs. pointers to > structs in C, or for objects in C++; the difference is that Objective-C > objects can only be referred to by pointers (you can't have a variable of > type "NSString", only "NSString*".) > > —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
[iPhone] add touches to MKAnnotationView
Hi, I have a subclass of MKAnnotationView,in which I create a custom pin (customPin, which is a UIImageView). I want to be able to move that custom Pin but I am having trouble. The touch event is being called, but my image is not moving. Here is my subclass: @implementation MyAnnotationView @synthesize customPin; - (void)dealloc { [customPin release]; [super dealloc]; } - (id)initWithAnnotation:(id )annotation reuseIdentifier:(NSString *)reuseIdentifier { if ((self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier])) { self.canShowCallout = YES; self.image = [UIImage imageNamed:@"Pin.png"]; self.centerOffset = CGPointMake(8, -14); self.calloutOffset = CGPointMake(-8, 0); customPin = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Pin.png"]]; customPin.frame = CGRectMake(0, 0, 32, 39); //customPin.hidden = YES; [self addSubview:customPin]; } return self; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"Touch"); UITouch *myTouch = [[event allTouches] anyObject]; customPin.center = [myTouch locationInView:self.superview]; [super touchesBegan:touches withEvent:event]; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"Touch Ended"); [super touchesEnded:touches withEvent:event]; } @end I am not sure what I am missing. Any help would be greatly appreciated. Thanks Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone] add touches to MKAnnotationView
Never mind... I got it. Thanks, Phil On Aug 18, 2010, at 8:42 PM, Philip Vallone wrote: > Hi, > > I have a subclass of MKAnnotationView,in which I create a custom pin > (customPin, which is a UIImageView). I want to be able to move that custom > Pin but I am having trouble. The touch event is being called, but my image is > not moving. > > Here is my subclass: > > > @implementation MyAnnotationView > @synthesize customPin; > > - (void)dealloc { >[customPin release]; >[super dealloc]; > } > > - (id)initWithAnnotation:(id )annotation > reuseIdentifier:(NSString *)reuseIdentifier { > > if ((self = [super initWithAnnotation:annotation > reuseIdentifier:reuseIdentifier])) { > self.canShowCallout = YES; > > self.image = [UIImage imageNamed:@"Pin.png"]; > self.centerOffset = CGPointMake(8, -14); > self.calloutOffset = CGPointMake(-8, 0); > > customPin = [[UIImageView alloc] initWithImage:[UIImage > imageNamed:@"Pin.png"]]; > customPin.frame = CGRectMake(0, 0, 32, 39); > //customPin.hidden = YES; > [self addSubview:customPin]; > } > return self; > } > > - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { > >NSLog(@"Touch"); >UITouch *myTouch = [[event allTouches] anyObject]; >customPin.center = [myTouch locationInView:self.superview]; > >[super touchesBegan:touches withEvent:event]; > > } > > > - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { > >NSLog(@"Touch Ended"); > >[super touchesEnded:touches withEvent:event]; > > } > > > @end > > I am not sure what I am missing. Any help would be greatly appreciated. > > Thanks > > Phil > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post 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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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
[iphone] Subclass MKAnnotationView - subtitle missing
Hi List, I have created a custom MKAnnotationView, which allows the user to move the MKAnnotationView. My problem is that the showCallOut does not show the subTitle. I am not sure what I am missing. Here is my .h #import #import @interface ViewShedAnnotationView : MKAnnotationView{ UIImageView *customPin; } @property (nonatomic, retain) UIImageView *customPin; @end Here is my .m #import "ViewShedAnnotationView.h" @implementation ViewShedAnnotationView @synthesize customPin; - (void)dealloc { [customPin release]; [super dealloc]; } - (id)initWithAnnotation:(id )annotation reuseIdentifier:(NSString *)reuseIdentifier { if ((self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier])) { self.canShowCallout = YES; self.image = [UIImage imageNamed:@"Pin.png"]; self.centerOffset = CGPointMake(8, -14); self.calloutOffset = CGPointMake(-8, 12); self.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; } return self; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *myTouch = [[event allTouches] anyObject]; self.center = [myTouch locationInView:self.superview]; [super touchesBegan:touches withEvent:event]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* aTouch = [touches anyObject]; CGPoint newLocation = [aTouch locationInView:[self superview]]; self.center = newLocation; [super touchesMoved:touches withEvent:event]; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesEnded:touches withEvent:event]; } @end Here is how I am instantiating it in my view controller: - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id ) mannotation{ ViewShedAnnotationView *annView=[[ViewShedAnnotationView alloc] initWithAnnotation:mannotation reuseIdentifier:@"currentloc"]; annView.calloutOffset = CGPointMake(-5, 5); return annView; } Thank you for the help. Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Memory question when added a view to the superView
Hi, If I create a view and add it to my superview, am I no longer the owner and do not have to release it? PinDetailsView *detailsView= [[PinDetailsView alloc] initWithFrame:CGRectMake(0, 0, 270, 420)]; detailsView.backgroundColor = [UIColor whiteColor]; CGRect frame = detailsView.frame; frame.origin = CGPointMake(25, self.view.bounds.size.height); detailsView.frame = frame; [self.view addSubview:detailsView]; [UIView beginAnimations:@"presentWithSuperview" context:nil]; frame.origin = CGPointMake(25, self.view.bounds.size.height - detailsView.bounds.size.height); detailsView.frame = frame; [UIView commitAnimations]; Thanks, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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 question when added a view to the superView
Thanks for the prompt replay. Ok I added autorelease: PinDetailsView *detailsView= [[[PinDetailsView alloc] initWithFrame:CGRectMake(0, 0, 270, 420)]autorelease]; Is this a correct way to release the object, or should I use [detailsView release]; Or is either acceptable? Thanks, On Sep 10, 2010, at 4:03 PM, Dave Carrigan wrote: > On Sep 10, 2010, at 12:57 PM, Philip Vallone wrote: >> If I create a view and add it to my superview, am I no longer the owner and >> do not have to release it? > > That's not how cocoa memory management works. Nothing can ever take ownership > from you; if you own something, you have to release it. If you add the view > to another view, the parent view also takes ownership, which means that there > are now two owners. But since you still own that view, you have to release it. > > -- > Dave Carrigan > d...@rudedog.org > Seattle, WA, USA > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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 question when added a view to the superView
Thanks Ken and Dave. Regards, Phil On Sep 10, 2010, at 5:19 PM, Ken Thomases wrote: > On Sep 10, 2010, at 4:11 PM, Dave Carrigan wrote: > >> On Sep 10, 2010, at 1:08 PM, Philip Vallone wrote: >>> >>> Thanks for the prompt replay. >>> >>> Ok I added autorelease: >>> >>> PinDetailsView *detailsView= [[[PinDetailsView alloc] >>> initWithFrame:CGRectMake(0, 0, 270, 420)]autorelease]; >>> >>> Is this a correct way to release the object, or should I use >>> >>> [detailsView release]; >>> >>> Or is either acceptable? >> >> The former is more idiomatic because you don't need to remember the release >> at the end. That is especially important if you were to change your code at >> some time in the future, such as adding a return statement sometime before >> the release, which would give you a memory leak. > > Except that Apple recommends, for iOS development particularly, that you use > -release rather than -autorelease when sensible. (If you're returning an > object to a caller, then it's not sensible to try to avoid -autorelease.) > > (There was a recent thread about when to do the -autorelease in the case that > you're going to do it. There, it was generally although not universally > recommended to do the autorelease in the same expression as the alloc and > init.) > > 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
[iOS] Sub Class MKPlacemark - Identifying each Placemark
Hi, I am need of some advice. I have a MKMapView which allows users to add a bunch of MKPlacemark's that I've subclassed. How can I uniquely identify each placemark so I can store or retrieve information about that placemark? Thanks for help. Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
MKPinAnnotationView was deallocated while key value observers were still registered with it
Hi, I am trying to add a KVO for my MKPinAnnotationView class. In my MapViewController which has an instance of a MKMapView, I have the following code: - (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views { for (MKAnnotationView *anAnnotationView in views) { [anAnnotationView addObserver:self forKeyPath:@"selected" options:NSKeyValueObservingOptionNew context:MAP_ANNOTATION_SELECTED]; } } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ NSString *action = (NSString*)context; NSLog(@"Selected"); if([action isEqualToString:MAP_ANNOTATION_SELECTED]){ // do something } } In my AnnotationView I try to remove the observer: - (void)dealloc { [self removeObserver:self forKeyPath:@"selected"]; [super dealloc]; } My MapViewController is a UIViewController. When I add some MKAnnotationViews, and the view is removed, I get the following error: An instance 0x6b778b0 of class MKPinAnnotationView was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: ( Context: 0x1722c, Property: 0x6b77ff0> I am a bit confused. I am not sure how to remove the observer... Thanks for the help, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: MKPinAnnotationView was deallocated while key value observers were still registered with it
I think I got it. for (id annotation in mapView.annotations) { [[mapView viewForAnnotation:annotation] removeObserver:self forKeyPath:@"selected"]; } Regards, Phil On Sep 11, 2010, at 7:49 AM, Philip Vallone wrote: > Hi, > > I am trying to add a KVO for my MKPinAnnotationView class. In my > MapViewController which has an instance of a MKMapView, I have the following > code: > > - (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views { > >for (MKAnnotationView *anAnnotationView in views) { > >[anAnnotationView addObserver:self > forKeyPath:@"selected" > options:NSKeyValueObservingOptionNew > context:MAP_ANNOTATION_SELECTED]; >} > > } > > - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object > change:(NSDictionary *)change context:(void *)context{ > >NSString *action = (NSString*)context; > NSLog(@"Selected"); >if([action isEqualToString:MAP_ANNOTATION_SELECTED]){ > // do something > > } > } > > > In my AnnotationView I try to remove the observer: > > - (void)dealloc { > > [self removeObserver:self forKeyPath:@"selected"]; > > [super dealloc]; > } > > My MapViewController is a UIViewController. When I add some > MKAnnotationViews, and the view is removed, I get the following error: > > An instance 0x6b778b0 of class MKPinAnnotationView was deallocated while key > value observers were still registered with it. Observation info was leaked, > and may even become mistakenly attached to some other object. Set a > breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the > current observation info: > ( > Options: Context: 0x1722c, Property: 0x6b77ff0> > > > > I am a bit confused. I am not sure how to remove the observer... > > Thanks for the help, > > Phil > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post 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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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: [iOS] Sub Class MKPlacemark - Identifying each Placemark
Thanks, This is a good idea. When you created the AddressAnnotation instances, what did you use as the Key (headlineKey), which made them unique? Thanks, Phil On Sep 11, 2010, at 1:00 PM, banane wrote: > for(NSString *headlineKey in [eDict allKeys]){ > float theLat = [[latDict objectForKey:headlineKey] doubleValue]; > float theLong = [[longDict objectForKey:headlineKey] > doubleValue]; > > CLLocationCoordinate2D theCoordinate; > theCoordinate.latitude = theLat; > theCoordinate.longitude = theLong; > > AddressAnnotation *theAnnot = [[AddressAnnotation alloc] > initWithCoordinate:theCoordinate andWithText:headlineKey > andWithSubtext:[eDict objectForKey:headlineKey]]; > //AddressAnnotation *theAnnot = [[AddressAnnotation alloc] > initWithCoordinate:theCoordinate andWithText:headlineKey]; > [self.mapView addAnnotation:theAnnot]; > > } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
NSMutableURLRequest google my maps help
Hi, I am trying to upload a xml file to google my maps that follows the following protocol: http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#uploading_xml POST http://maps.google.com/maps/feeds/maps/userID/full Content-type: application/atom+xml Authorization: GoogleLogin auth="authorization_token" http://www.w3.org/2005/Atom";> My Map My Description I am using the following code: if (appDelegate.authGoogleKey != nil) { NSString *urlStr = [NSString stringWithFormat:@"//maps.google.com/maps/feeds/maps/%@/full", txtEmail.text]; NSURL *url = [NSURL URLWithString:urlStr]; NSMutableURLRequest *uploadRequest = [NSMutableURLRequest requestWithURL:url]; [uploadRequest setHTTPMethod:@"POST"]; //set headers [uploadRequest addValue:@"Content-Type" forHTTPHeaderField:@"application/atom+xml"]; [uploadRequest addValue:@"Authorization" forHTTPHeaderField:@"GoogleLogin"]; [uploadRequest addValue:@"auth" forHTTPHeaderField:appDelegate.authGoogleKey]; NSString *requestBody = @"http://www.w3.org/2005/Atom\";>My MapMy Description"; [uploadRequest setHTTPBody:[requestBody dataUsingEncoding:NSASCIIStringEncoding]]; NSData *returnData = [NSURLConnection sendSynchronousRequest:uploadRequest returningResponse:nil error:nil]; NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; NSLog(@"Response: %@ ", returnString); [returnString release]; }else{ NSLog(@"Not logged in"); } I am not getting a response back, which indicates my post method is wrong. Can anyone help me out? 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSMutableURLRequest google my maps help
Thanks Jerry. Works perfect! Regards, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
[iPad] Using UISplitViewController with a UITabBarController - UIPopoverController - Question
Hi, I hope I can explain my issue correctly. I have a UISplitViewController which uses a UITabBarController as the Details view. Everything works except on my UITabBarController I can not see the UIPopoverController on the Navigation Bar. I have a class called DetailViewTabBarController which is the detail view for the Spilt View. The below code is how I am creating the TabBarController and how I implemented the popoverController and Spilt view Protocols. Thanks for the help. DetailViewTabBarController.m - (void)loadView { UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; contentView.backgroundColor = [UIColor whiteColor]; self.view = contentView; navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 1004, 60)]; [contentView release]; FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstView" bundle:nil]; SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil]; firstViewController.title = @"New Project"; secondViewController.title = @"My Sites"; tabBarController = [[UITabBarController alloc] init]; tabBarController.view.frame = CGRectMake(0, 0, 768, 1004); // Set each tab to show an appropriate view controller [tabBarController setViewControllers:[NSArray arrayWithObjects:firstViewController, secondViewController, nil]]; [firstViewController release]; [secondViewController release]; [self.view addSubview:tabBarController.view]; } #pragma mark - #pragma mark Managing the popover controller - (void)setDetailItem:(id)newDetailItem { if (detailItem != newDetailItem) { [detailItem release]; detailItem = [newDetailItem retain]; // Update the view. navigationBar.topItem.title = [detailItem description]; } if (popoverController != nil) { [popoverController dismissPopoverAnimated:YES]; } } #pragma mark - #pragma mark Split view support - (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc { barButtonItem.title = @"Table of Contents"; [navigationBar.topItem setLeftBarButtonItem:barButtonItem animated:YES]; self.popoverController = pc; } - (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem { [navigationBar.topItem setLeftBarButtonItem:nil animated:YES]; self.popoverController = nil; } Regards, Philip Vallone ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
[iPhone] iterate through all the MKPolygons on my map view
Hi, I have added some MKPolygons to my map view. I want to loop through all my polygons and delete the one that has a certain title. My question is; how do I access the properties of the mkpolygon after the overlays have been added to the map view. This is how I am creating the MKPolygon MKPolygon* poly = [MKPolygon polygonWithCoordinates:points count:[myPoints count]]; poly.title = @"someName"; self.strokeColor = [[UIColor redColor] colorWithAlphaComponent:0.5]; [mapView addOverlay:poly]; In this loop, I am trying to access all the overlays, But I don't know how to access the MKPolygon. How do I iterate through all the MKPolygons on my map view? for (id overlay in mapView.overlays) { //todo access polygons title property } Thanks Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone] iterate through all the MKPolygons on my map view
Never mind - > overlay.title does the trick - duh On Nov 13, 2010, at 8:51 AM, Philip Vallone wrote: > Hi, > > I have added some MKPolygons to my map view. I want to loop through all my > polygons and delete the one that has a certain title. My question is; how do > I access the properties of the mkpolygon after the overlays have been added > to the map view. > > This is how I am creating the MKPolygon > > MKPolygon* poly = [MKPolygon polygonWithCoordinates:points count:[myPoints > count]]; > poly.title = @"someName"; > self.strokeColor = [[UIColor redColor] colorWithAlphaComponent:0.5]; > [mapView addOverlay:poly]; > > In this loop, I am trying to access all the overlays, But I don't know how to > access the MKPolygon. How do I iterate through all the MKPolygons on my map > view? > > for (id overlay in mapView.overlays) { > > //todo access polygons title property > > } > > Thanks > > Phil > > > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post 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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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
iOS - Help with nasty memory leak
Hi, I have implemented a dragable annotation in my app. I am getting a 100% memory leak that has me puzzled. I was hoping that someone can provide some guidance. The leak is at: MKAnnotationView *draggablePinView = [[[AnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"PinIdentifier"] autorelease]; Here is the entire method: - (MKAnnotationView *)mapView:(MKMapView *)MapView viewForAnnotation:(id )annotation { MKAnnotationView *draggablePinView = [[[AnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"PinIdentifier"] autorelease]; if (draggablePinView) { draggablePinView.annotation = annotation; } else { if ([draggablePinView isKindOfClass:[AnnotationView class]]) { ((AnnotationView *)draggablePinView).mapView = MapView; } } ((MKPinAnnotationView *)draggablePinView).pinColor = MKPinAnnotationColorGreen; ((MKPinAnnotationView *)draggablePinView).animatesDrop = YES; return draggablePinView; } The analizer says the leak is AnnotationView. So I can't see anything in AnnotationView that would cause the leak: #import "AnnotationView.h" #import "CurrentLocationAnnotation.h" @implementation AnnotationView @synthesize hasBuiltInDraggingSupport; @synthesize mapView; - (void)dealloc { [super dealloc]; } - (id)initWithAnnotation:(id )annotation reuseIdentifier:(NSString *)reuseIdentifier { self.hasBuiltInDraggingSupport = [[MKPinAnnotationView class] instancesRespondToSelector:NSSelectorFromString(@"isDraggable")]; if (self.hasBuiltInDraggingSupport) { if ((self = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIdentifier])) { [self performSelector:NSSelectorFromString(@"setDraggable:") withObject:[NSNumber numberWithBool:YES]]; } } self.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; self.canShowCallout = YES; UIImage *image = [UIImage imageNamed:@"gps_add.png"]; UIImageView *imgView = [[[UIImageView alloc] initWithImage:image] autorelease]; self.leftCalloutAccessoryView = imgView; self.image = image; return self; } @end Thanks for any help and guidance. Phil___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS - Help with nasty memory leak
Thank you, My viewForAnnotation was all wrong. I was trying code from this tutorial: http://trentkocurek.wordpress.com/2010/07/21/ios4-map-kit-draggable-annotation-views/ So, I went back and redid my code, which fixed the memory leak and alleviated the need for a custom Annotation View. - (MKAnnotationView *)mapView:(MKMapView *)MapView viewForAnnotation:(id )annotation { MKPinAnnotationView *pin = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"PinIdentifier"]; if (pin == nil) { pin = [[[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"PinIdentifier"] autorelease]; }else { pin.annotation = annotation; } pin.pinColor = MKPinAnnotationColorGreen; pin.animatesDrop = YES; pin.draggable = YES; pin.canShowCallout = YES; pin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; UIImage *image = [UIImage imageNamed:@"gps_add.png"]; UIImageView *imgView = [[[UIImageView alloc] initWithImage:image] autorelease]; pin.leftCalloutAccessoryView = imgView; return pin; } Thanks a bunch, Phil On Nov 27, 2010, at 11:50 AM, Joar Wingfors wrote: > > On 27 nov 2010, at 06.33, Philip Vallone wrote: > >> if ((self = [[MKPinAnnotationView alloc] >> initWithAnnotation:annotation reuseIdentifier:reuseIdentifier])) { >> [self >> performSelector:NSSelectorFromString(@"setDraggable:") withObject:[NSNumber >> numberWithBool:YES]]; >> } > > > You're replacing the current instance with a new instance here. Is that > intended? While not illegal, it is really unusual to do that. > > If that's intended, you also would have to release the old instance before > replacing it with the new instance (that's the leak). If that was not > intended, you probably should be calling [super initWithAnnotation:annotation > reuseIdentifier:reuseIdentifier], and in any case, you need to make sure that > you *always* call through to the designated initializer of your superclass > somewhere in your init method. > > Finally, why are you calling a method using "-performSelector:withObject:" > here? That seems like a trick to "fix" a compiler warning? If so, you should > think about why the compiler were warning you about that call, and fix it > properly - by adding the required #import statement, by adding the missing > method declaration to the header, or - if all else fails - by casting the > receiver to the appropriate type. > > > j o a r > > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Search with a UIWebView (iOS 4.2)
Hi List, In iOS 4.2, you can search within a webpage in Safari. Is there a search bar object that can do this in a UIWebView? Thanks, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Search within a UIWebView (iOS 4.2)
Hi List, I was wondering if any one could provide some guidance on this? Thanks, Phil On Dec 26, 2010, at 2:04 PM, Philip Vallone wrote: > Hi List, > > In iOS 4.2, you can search within a webpage in Safari. Is there a search bar > object that can do this in a UIWebView? > > Thanks, > > Phil > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post 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/philip.vallone%40verizon.net > > This email sent to philip.vall...@verizon.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
Core Data one to many insert question
Hi List, I have an Entity called "CDSites" which has a one-to-many relationship with an Entity called "CDPlacemarks". CDSites is the "Parent" and CDPlacemarks are the "Children". My Applications allows the users to create many CDSites like this: CDSites *cdSites = [NSEntityDescription insertNewObjectForEntityForName:@"CDSites" inManagedObjectContext:context]; cdSites.prjName = self.newDetailsView.prjName; cdSites.street = self.newDetailsView.street; cdSites.city = self.newDetailsView.city; cdSites.state = self.newDetailsView.prjState; cdSites.zip = self.newDetailsView.zip; cdSites.latitude = [NSNumber numberWithFloat:self.newDetailsView.latitude]; cdSites.longitude = [NSNumber numberWithFloat:self.newDetailsView.longitude]; NSError *error; if (![context save:&error]) { NSLog(@"Couldn't save: %@", [error localizedDescription]); } CDSites is a subclass of NSManagedObject. This works well. My question is, I need to create the CDPlacemarks for each CDSite. How do I associate my CDPlacemarks with its "Parent" CDSites? Thanks for the help. Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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 one to many insert question
Thanks. I had used X-code to create the subclasses. I see that it created the required methods for adding the "children". Thanks for the help. If I have any issues, I'll post a new question. Regards, Phil On Jan 14, 2011, at 8:07 AM, Pablo Pons Bordes wrote: > You need to declare some method that core date implement for you, for this > situations, to make your life easier XCode help you to declare it and declare > those custom class file declarations: > > - At your Core Date model select the entities you want to make a custom class. > - go to Menu File>New File... > - At Cocoa Class or (Cocoa Touch Class, depend what you are doing) you find a > New File Type, Managed Object Class. > - Select it and create the classes. > > Then you will see is really easy. > > NOTE: When you do this the old implementation you have will me deleted, > refactor it before you make the classes if you don't want to lost what you > did before. > > Pablo Pons > > > > > > > El 14/01/2011, a las 12:53, Philip Vallone escribió: > >> >> Hi List, >> >> I have an Entity called "CDSites" which has a one-to-many relationship with >> an Entity called "CDPlacemarks". CDSites is the "Parent" and CDPlacemarks >> are the "Children". My Applications allows the users to create many CDSites >> like this: >> >> >>CDSites *cdSites = [NSEntityDescription >> insertNewObjectForEntityForName:@"CDSites" inManagedObjectContext:context]; >>cdSites.prjName = self.newDetailsView.prjName; >>cdSites.street = self.newDetailsView.street; >>cdSites.city = self.newDetailsView.city; >>cdSites.state = self.newDetailsView.prjState; >>cdSites.zip = self.newDetailsView.zip; >>cdSites.latitude = [NSNumber >> numberWithFloat:self.newDetailsView.latitude]; >>cdSites.longitude = [NSNumber >> numberWithFloat:self.newDetailsView.longitude]; >> >> >>NSError *error; >>if (![context save:&error]) { >>NSLog(@"Couldn't save: %@", [error localizedDescription]); >>} >> >> >> CDSites is a subclass of NSManagedObject. >> >> This works well. My question is, I need to create the CDPlacemarks for each >> CDSite. How do I associate my CDPlacemarks with its "Parent" CDSites? >> >> Thanks for the help. >> >> Phil >> >> >> >> ___ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post 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/pablo.mailinglists%40gmail.com >> >> This email sent to pablo.mailingli...@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
Core Data Model One-To-Many question/help
Hi List, I am trying to learn core data and have a very basic question on how to set up a one-to-many relationship. Can someone look at the screen shots (links below) and provide some guidance. Do I have this set up correctly? CDSites CDAnnotations My Entity "CDSites" will have Many "CDAnnotations". Thanks for the help. Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
iOS Pass NSManagedObjectContext from my app delegate
Hi, Whats the best way to pass a NSManagedObjectContext object from an app delegate to other view controllers? Currently, my NSManagedObjectContext is retained like this in my app delegate: @property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext; @private NSManagedObjectContext *managedObjectContext_; } and in my implementation: - (NSManagedObjectContext *)managedObjectContext { if (managedObjectContext_ != nil) { return managedObjectContext_; } NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; if (coordinator != nil) { managedObjectContext_ = [[NSManagedObjectContext alloc] init]; [managedObjectContext_ setPersistentStoreCoordinator:coordinator]; } return managedObjectContext_; } In my view controllers, I create another NSManagedObjectContext Object and pass the reference like this: @property (nonatomic, retain) NSManagedObjectContext *context; Implementation: CameraPlanAppDelegate *appDelegate = (CameraPlanAppDelegate *)[[UIApplication sharedApplication] delegate]; context = [appDelegate managedObjectContext]; Is this correct? Do I need to release "context" on my view controller? If I release it, don't I release all references to it? Thanks. Phil___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS Pass NSManagedObjectContext from my app delegate
Hi Nick, > Did you use the Xcode template for making a CoreData application? Yes > If you have declared the property to be read-only, then the retain keyword is > not necessary. Retain and assign are only necessary if it's a read/write > property, since they tell the synthesizer what to do with new values (if > @synthesize is in use). This was created by xcode... so it should be: @property (nonatomic, readonly) NSManagedObjectContext *managedObjectContext; Thanks for the help Phil___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
iOS Setting frame size for MKAnnotationView
Hi, I am having trouble setting the size of the "call out bubble" on my viewForAnnotation protocol. How can I set the frame size of the call out? This line has no effect: [callout setFrame:CGRectMake(0, 0, 240, 240)]; Here is my code: - (MKAnnotationView *)mapView:(MKMapView *)MapView viewForAnnotation:(id )annotation { MKPinAnnotationView *callout = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"PinIdentifier"]; [callout setFrame:CGRectMake(0, 0, 240, 240)]; if (callout == nil) { callout = [[[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"PinIdentifier"] autorelease]; }else { callout.annotation = annotation; } callout.pinColor = MKPinAnnotationColorGreen; callout.animatesDrop = YES; callout.draggable = YES; callout.canShowCallout = YES; callout.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; UIImage *image = [UIImage imageNamed:@"gps_add.png"]; UIImageView *imgView = [[[UIImageView alloc] initWithImage:image] autorelease]; callout.leftCalloutAccessoryView = imgView; return callout; } thanks, Phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS Setting frame size for MKAnnotationView
> but that doesn't magically turn it into the callout Well that explains it :) 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com