MGTwitterEngine currentNode is unavailable - ios

I am using the MGTwitterEngine in an iOS app that was built by a third party. I have taken over development but have limited experience in objective c.
I am getting an error: 'currentNode' is unavailable.
This is in the MGTwitterXMLParser.m file. The interface has a weak link like this:
__weak NSMutableDictionary *currentNode;
I had to add the libOAuth.a file because it was missing and I am wondering if this is the cause. Do I need a certain version of libOAuth?
The weird part is that it worked with the new libOAuth.a until I updated XCode to the latest version which is 7.3. Is anyone having issues with MGTwitterEngine in 7.3?
UPDATE:
In XCode (I was compiling in AppCode) I now see that it says, "Declaration uses __weak, but ARC is disabled."
This is in MGTwitterXMLParser:
__weak NSMutableDictionary *currentNode;
My project has ARC enabled and I don't see any way to set ARC for the MGTwitterEngine or any individual files. Is there a way to do this?

Okay, the answer was simple once I understood the problem. I simply needed to discard the __weak for the NSMutableDictionary and it compiled.
Still need to test Twitter and look for any memory leaks. Also, not sure how the app ever compiled before with a __weak reference in a non-ARC file.

Related

MITM attack reported on deprecated NSURLConnectionDelegate

I have an Objective-C project whose .ipa was tested with this tool online: https://www.immuniweb.com/mobile
It reports that my app has a high risk security issue, pointing to the canAuthenticateAgainstProtectionSpace in the NSURLConnectionDelegate protocol.
This method has been deprecated by iOS after 8.0 version. My app is not using it directly anywhere and I suppose this is not used by apple also even indirectly, since it is deprecated.
I tried a sample ipa (new project with nothing in it) with Objective-C project and the same issue came for that as well. But it did not come for a sample ipa which supported Swift. Even if this is just a warning, is there a way to fix other than just supporting Swift language only?
The tool has detected that the .h file that defines the NSURLConnectionDelegate protocol declares the canAuthenticateAgainstProtectionSpace function. This is, of course, to be expected.
It would make more sense for the tool to report implementations of the method, not simply declarations of it
Since you haven’t implemented this method you don’t need to worry about flaws in your implementation.
As for getting rid of the issue...Don’t use the tool? It doesn’t seem very good based on this.
Is there an option to tell it not to scan .h files?
TBH it seems like a bug in the tool if not any of your Libraries or Frameworks internally uses that.
In your test for the sample Objective C project it's reported as bug however for a sample swift project it's not reported Hence I guess it's more of bug from the tool side.
I would suggest you to report this issue to them.Hopefully they will get you back with some suggestions.
or
you can try some other pen-testing tools as well.

Compiler Errors Adding AFNetwork to Xcode

I've looked at all the questions on StackOverflow regarding this, and nothing has helped. I followed this tutorial for setting up the AFNetworking library with xcode to use for my project, however I am getting this error in the AFURLSessionManager.m file:
Semantic Issue: #synthesize of 'weak' property is only allowed in ARC or GC mode
and a yellow caution sign for the same file:
Semantic Issue: Method possibly missing a [super dealloc] call
I'm very lost at this point since I'm fairly new to iOS development to begin with, and adding this framework has been nothing but frustration.
why you don't use Cocoapods. With me that's the best one to import a library. Try and you will like it.

Transitioning one separate file to arc

I have a project that is already transitioned to ARC. Now I'm trying to include an existing file from the other project, which is not using ARC and I want it to be ARC-compliant too: release-retains, [super dealloc]s gone from this file, quick fixes, other stuff "Convert to Objective-C ARC..." does.
The problem is I can't use the Edit->Refactor->"Convert to Objective-C ARC..." tool for this. If I select only this file in "Select Targets to Convert" screen I'm getting "Cannot Convert to Objective-C ARC" message because of errors like: "#synthesize of 'weak' property is only allowed in ARC or GC mode". But they are already in ARC mode indeed! Also numerous warnings: "Method possibly missing a [super dealloc] call"
If I select all files except marked with -fno-objc-arc while converting, I get only errors about weak properties.
Of course I can build and delete the release-retains manually but why to walk if there is a bus (Conversion tool)... So can I auto-transition a separate file to ARC?
Update: I do not want ARC to be turned off for this file with -fno-objc-arc flag, I want ARC used in this file.
If you insist on making Xcode do the work, create a new Xcode project and deselect "Use ARC" when creating it. Add the files to convert, and convert the project to ARC. Take the modified files and import them into your other project.
It's probably simpler, however, to convert the file manually. This is not difficult, even for a large file or an entire project. Just lean on the compiler: build your app, walk through the errors and simply delete all retain/release calls and convert any NSAutoreleasePools to #autoreleasepool {}. You may also need to add __bridge casts if interacting with core foundation types.
It sounds like you'll have to convert this file to ARC manually, instead of relying on the automatic conversion tool. You'll need to go through the file and remove all of the release, retain etc. I've done this before, and while it takes a while, it's not too painful. Rely on the error messages from Xcode to guide you what needs to be fixed/removed in the code.
Here's a couple of links I found that may help. Also look at Apple's ARC docs and WWDC 2011 talks (referenced at the bottom of the second link).
Xcode ARC conversion tool issue
http://blog.mugunthkumar.com/articles/migrating-your-code-to-objective-c-arc/

write an iOS 5.1 app that uses a web service

I am fairly new to iOS programming and I'm trying to make an iOS 5.1 app that communicates with a server to receive information from a database. I got the server returning the needed information from the database by following this tutorial:
http://www.raywenderlich.com/2941/how-to-write-a-simple-phpmysql-web-service-for-an-ios-app
But then I tried to follow a the other half of the tutorial by the same guy:
http://www.raywenderlich.com/2965/how-to-write-an-ios-app-that-uses-a-web-service
In this one we use JSON, ASIHTTPRequest and MBProgressHUD, but I get a lot of errors when I run this because ASIHTTPRequest is no longer supported in iOS 5.1.
Can anyone point me in the right direction here? I you can show me another tutorial that works for iOS 5.1 that would be great. I have looked but I can't find any.
Thanks
ASIHTTPRequest is most likely returning errors in your iOS 5.1 app because you're using ARC. ASIHTTPRequest wasn't written in ARC, which is why it's throwing tons of errors. But there's an easy workaround:
In Xcode 4's groups and files pane, select your project file at the top of the list.
Select your target towards the left hand panel.
You should now see a list of all the implementation (.m) files referenced and compiled throughout the course of the program.
Double click the implementation files for ASIHTTPRequest and add the following linker flag: -fno-objc-arc. This linker flag acts as a crossbridge between the old non-ARC files and your ARC-based project.
Although there may be residual warnings left, this trick should remove all other error messages associated with ASIHTTPRequest.
When I followed that same tutorial I got a lot of errors. and the build kept failing until I reliased it was because libz.1.2.3.dylib wasnt there. If you go to Build Phases, remove that from the list and add libz.1.2.5.dylib all mine worked first and I got the app working fully :)

SBJson - has memory leaks?

I just cloned the git repository for the SBJson framework and imported the source code into my application. Ran a Static Memory profiler and got a little scared from the results I saw.
See the picture
How is this possible? I doubt the developer of this very well known library didn't see this? And indeed, if a run a memory profile it shows memory leaks from this library.
Any ideas?
Thx
It looks like you're using SBJSON in a project that doesn't have ARC enabled. Since ARC removes the need to call release explicitly, code written for ARC (like SBJSON) causes memory leaks when used in a non-ARC project. You should convert your project to use ARC with the built-in refactoring tool (Edit > Refactor > Convert to Objective-C ARC, then explicitly set the -fno-objc-arc compiler flag on any of your source that is not yet ARC-ready.

Resources