Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-09-2011, 07:53 AM   #1 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Exclamation ShareKit Warnings

I am getting the following 3 warnings in these pictures from ShareKit:
1.

2.

3.


I have googled these warnings but have found nothing.
Does anyone know how to fix these warnings?

Thanks!
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 08-09-2011, 07:56 AM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 140
MatthewD is on a distinguished road
Default

1 & 2: You are passing a class. You need to pass an instance of the class that adopts the protocols.
3: You need to cast.
MatthewD is offline   Reply With Quote
Old 08-09-2011, 04:44 PM   #3 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Quote:
Originally Posted by MatthewD View Post
1 & 2: You are passing a class. You need to pass an instance of the class that adopts the protocols.
3: You need to cast.
I fixed #1 with making the delegate: as

2. I tried doing something similar that I did with #1 but for #2 but it didn't work. Any thoughts?

3. What do I need to cast?
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 08-09-2011, 05:17 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

1 / 2. You need to assign an instance of an object as the delegate, not a class.

3. You need to cast [aResponse retain];
harrytheshark is offline   Reply With Quote
Old 08-09-2011, 05:28 PM   #5 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

So for #2, I am confused why this would not work:
Code:
+ (void)logout
{
	FBSession *fbSession; 
	
	if(!SHKFacebookUseSessionProxy){
		fbSession = [FBSession sessionForApplication:SHKFacebookKey
												 secret:SHKFacebookSecret
											   delegate:fbSession];
		
	}else {
		fbSession = [FBSession sessionForApplication:SHKFacebookKey
										getSessionProxy:SHKFacebookSessionProxyURL
											   delegate:fbSession];
	}

	[fbSession logout];
}
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 08-09-2011, 05:31 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

You're making it its own delegate. Is this your intention?

What do you mean when you say it doesn't work? Are you getting the same warning, is it crashing, etc?
harrytheshark is offline   Reply With Quote
Old 08-09-2011, 05:34 PM   #7 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Quote:
Originally Posted by harrytheshark View Post
You're making it its own delegate. Is this your intention?

What do you mean when you say it doesn't work? Are you getting the same warning, is it crashing, etc?
Well I am just trying to achieve the same functionality while fixing these warnings and yes it is the same warning.
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 08-09-2011, 05:36 PM   #8 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

Just set the delegate to nil. That'll get rid of the warning.
harrytheshark is offline   Reply With Quote
Old 08-09-2011, 05:38 PM   #9 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Thanks that did it, will that effect the functionality though?

Also what did you say I should do to fix #3? I should cast it?
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 08-09-2011, 05:39 PM   #10 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

Well yeah of course, it won't have a delegate to call.

Yup, use a cast for 3.
harrytheshark is offline   Reply With Quote
Old 08-09-2011, 05:54 PM   #11 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Thanks let me ask you this, with that warning before for #2, would it have worked anyway or no?
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 08-09-2011, 05:57 PM   #12 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

Unless FBSession can respond to its own delegate, no. Also, I think at the time you set the delegate, the pointer for FBSession is nothing. No, it wouldn't work.
harrytheshark is offline   Reply With Quote
Old 08-09-2011, 07:21 PM   #13 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Hey I have another weird problem with ShareKit leaks here:
Whenever I clearly release something, analyzer complains that there is a leak even though there is not. I am using Beta 5 of the iOS SDK so I don't think its a bug.

A few examples:

self.data = [[NSMutableData alloc] initWithLength:0];
[data release];

if (toggle == nil)
{
self.toggle = [[UISwitch alloc] initWithFrame:CGRectZero];
[self.contentView addSubview:toggle];
[self setValue:tmpValue];
[toggle release];
}

Any ideas?

Thanks!
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 08-09-2011, 08:13 PM   #14 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

The analyzer gets stuff wrong, but it's probably better to create temporary pointers then use the setters, rather than what you're doing.

Code:
UISwitch * temp = ...
self.toggle = temp;
[temp release];
harrytheshark is offline   Reply With Quote
Old 08-09-2011, 08:19 PM   #15 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Alright so this would be the way to do it for the 1st example?:
Code:
NSMutableData *tempdata = [[NSMutableData alloc] initWithLength:0];
	self.data = tempdata;
	[tempdata release];
That gets rid of the analyzer warning, [data release]; does not.
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 08-09-2011, 08:21 PM   #16 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

Yeah, though initWithLength:0 is the same as init.
harrytheshark is offline   Reply With Quote
Old 08-09-2011, 09:18 PM   #17 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Thanks,

I have gotten it down to 6 (Edit: Now 5) leaks/minor analyzer problems left that are a bit different from the others:
(Bold line is where I alloc it)
1.
Code:
+ (void)flushOfflineQueue
{
	// TODO - if an item fails, after all items are shared, it should present a summary view and allow them to see which items failed/succeeded
	
	// Check for a connection
	if (![self connected])
		return;
	
	// Open list
	NSMutableArray *queueList = [self getOfflineQueueList];
	
	// Run through each item in the quietly in the background
	// TODO - Is this the best behavior?  Instead, should the user confirm sending these again?  Maybe only if it has been X days since they were saved?
	//		- want to avoid a user being suprised by a post to Twitter if that happens long after they forgot they even shared it.
	if (queueList != nil)
	{
		SHK *helper = [self currentHelper];
		
		if (helper.offlineQueue == nil)
			helper.offlineQueue = [[NSOperationQueue alloc] init];
	
		SHKItem *item;
		NSString *sharerId, *uid;
		
		for (NSDictionary *entry in queueList)
		{
			item = [SHKItem itemFromDictionary:[entry objectForKey:@"item"]];
			sharerId = [entry objectForKey:@"sharer"];
			uid = [entry objectForKey:@"uid"];
			
			if (item != nil && sharerId != nil)
				[helper.offlineQueue addOperation:[[[SHKOfflineSharer alloc] initWithItem:item forSharer:sharerId uid:uid] autorelease]];
		}
		
		// Remove offline queue - TODO: only do this if everything was successful?
		[[NSFileManager defaultManager] removeItemAtPath:[self offlineQueueListPath] error:nil];

	}
}
[FIXED] 2.
Code:
- (void)share
{	
	// create sharer
    SHKSharer *tempsharer = [[NSClassFromString(sharerId) alloc] init];
	self.sharer = tempsharer;
	sharer.item = item;
	sharer.quiet = YES;
	sharer.shareDelegate = self;
	
	if (![sharer isAuthorized])		
	{
		[self finish];
		return;
	}
	
	// reload image from disk and remove the file
	NSString *path;
	if (item.shareType == SHKShareTypeImage)
	{
		path = [[SHK offlineQueuePath] stringByAppendingPathComponent:uid];
		sharer.item.image = [UIImage imageWithContentsOfFile:path];
		[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
		
	}
	
	// reload file from disk and remove the file
	else if (item.shareType == SHKShareTypeFile)						
	{
		path = [[SHK offlineQueueListPath] stringByAppendingPathComponent:uid];
		sharer.item.data = [NSData dataWithContentsOfFile:[[SHK offlineQueuePath] stringByAppendingPathComponent:uid]];
		[[NSFileManager defaultManager] removeItemAtPath:path error:nil]; 

	}
	
	[sharer tryToSend];	
    [tempsharer release];
}
I tried it this way like I did for my other problems but no luck.

3.
Code:
 /* Wipe variables */
    a = b = c = d = e = 0;
That is not a leak but a value stored to 'a' is never read.

[FIXED]4.
Code:
- (void)_generateNonce
{
    CFUUIDRef theUUID = CFUUIDCreate(NULL);
    CFStringRef string = CFUUIDCreateString(NULL, theUUID);
    CFRelease(theUUID);
    nonce = (NSString *)string;
}
The warning is, Potential leak on line 202 (Bolded line)

6. Argument in message expression is an uninitialized value
Code:
SHKActionSheet *as = [[SHKActionSheet alloc] initWithTitle:SHKLocalizedString(@"Share")
													  delegate:as
											 cancelButtonTitle:nil
										destructiveButtonTitle:nil
											 otherButtonTitles:nil];
	as.item = [[[SHKItem alloc] init] autorelease];
	as.item.shareType = type;
Those are the only problems left with ShareKit, I would love to share this updated ShareKit with others having these issues too!

Thanks!
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8

Last edited by Objective Zero; 08-10-2011 at 06:59 PM. Reason: Update4
Objective Zero is offline   Reply With Quote
Old 08-10-2011, 04:42 AM   #18 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

You know how to fix 1 and 2 because they're exactly the same problem we discussed earlier.

3. Doesn't make any sense, I don't see a _ anywhere, but I imagine one of those letters is never used - check for that.

4. What's the problem / warning?

5. Which line is it complaining about?
harrytheshark is offline   Reply With Quote
Old 08-10-2011, 07:06 AM   #19 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

I updated my post above, also don't worry about #5, I fixed that. Also how about 6? Also I am not sure how to fix #1 because it is not a self.whatever, it is a helper.whatever so what would I do in that case? Also, I updated #2's code with the way that should fix it but it stills complains about a leak

Thanks
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8

Last edited by Objective Zero; 08-10-2011 at 07:12 AM.
Objective Zero is offline   Reply With Quote
Old 08-10-2011, 07:09 AM   #20 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

3. Come on, this is the most simple one.

4. Well yeah, there is a potential leak if "nonce" doesn't get released.
harrytheshark is offline   Reply With Quote
Old 08-10-2011, 07:19 AM   #21 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Ok for #3 my best guess is to delete it if it says its not being used right?

Also I updated #4 above with a [noonce release]; and it still shows a warning.

Also recheck all the code because I think I updated it all.

Thanks!
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 08-10-2011, 07:41 AM   #22 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

Replace NSMakeCollectable(theUUID); with CFRelease(theUUID);

You don't want to be releasing nonce in the same method, you'll get a crash if it's used elsewhere.
harrytheshark is offline   Reply With Quote
Old 08-10-2011, 06:31 PM   #23 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Thanks, that fixed it. Now what about #1,#2,#3, and #6. I thought that just by deleting #3 code line would fix the analyzer warning wouldn't it? And for #1, and #2, I tried your suggestion but I edited my long code post on why/how it didn't work.
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 08-10-2011, 06:35 PM   #24 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

For 2 you shouldn't be releasing sharer in that method - you really need to read up on properties. BrianSlick has a good post on them.
harrytheshark is offline   Reply With Quote
Old 08-10-2011, 06:39 PM   #25 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Quote:
Originally Posted by harrytheshark View Post
For 2 you shouldn't be releasing sharer in that method - you really need to read up on properties. BrianSlick has a good post on them.
I updated that code taking out [sharer release]; but it still throws up a analyzer warning in that bolded line. In the meantime I will look over BrianSlick's properties guide but this one just baffles me on why it should be showing a warning whatsoever.
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Reply

Bookmarks

Tags
sharekit warning

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 400
15 members and 385 guests
7twenty7, blasterbr, chiataytuday, cristofercolmbos, dedeys78, dre, fiftysixty, gmarro, HemiMG, jimmyon122, jonathandeknudt, pungs, raymng, tymex, UMAD
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:06 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0