ios


obejective c - Portential leak of an object stored into


I am trying to Run the code but its reporting the memory leaks when using static analyzer. on this line as Potential leak of an object stored into 'encodedData'
return encodedData;
use __bridge_transfer
Using __bridge_transfer ensures that ARC will release the object for you. Without __bridge_transfer, you must release the returned object manually.
__bridge,__bridge_transfer keywords are used to tell to ARC system how to handle your non-objective-c pointers. In essence, if you use __bridge, you are telling to ARC not to deal with the ownership of the converted pointer because you will free it from non-objective-c code, most likely with a free() or a CFRelease... type function. __bridge_transfer, on the other hand, transfers the ownership to ARC and ARC will free your objective-c (and thus also the original non-objective-c) object via the standard release mechanism when the references to that object hits zero.
Reference
The problem is that you create your string using CoreFoundation methods. And by default ARC doesn't know what to do with it. So, you're responsible for either manually managing the memory for the created object (using CFRelease for example), or handing it over to ARC.
The later is, I believe, the way to go in your case. You can do it, as others have already noted, using __bridge_transfer.

Related Links

tell an array to hold instances of an array?
Add Vibrancy effect to custom UIButton?
Image buffer display order with VTDecompressionSession
What is that? Cell or Table? [closed]
Setting up proxy server on iPhone
iOS/FBSDK - FBSDKProfile is nil on device, works fine on simulator
NSMutableAttributedString check nil value [duplicate]
How to use cocoapods with playground?
iOS: Switch UIViews using ReactiveCocoa
AFNetworking HTTP POST Success Empty
exc_bad_access on touch UITextField
Deleting items in Core Data
iOS: Find language of current location
addSubView - adding a button inside a UIView adds the same button for it's SuperView as well
How can I access the associated values of SwiftyDropbox errors?
CNSaveRequest returns “Updated Record Does Not Exist”

Categories

HOME
html5-canvas
common-lisp
web-services
performance-testing
graylog2
blogs
redhat
normalization
geany
go-gorm
webdriver-io
square-connect
development-environment
frequency
vscode-settings
asp.net-mvc-5.2
jsqmessagesviewcontroller
spring-cloud-consul
zap
gas
media-source
rtp
django-autocomplete-light
c-strings
hough-transform
weather-api
unsigned-integer
code-signing
physics
x-sendfile
temp
apscheduler
lync
dokuwiki
chai
vrtk
server-sent-events
nio
ecdsa
knowledge-management
es6-promise
mamp-pro
angular2-seed
projection
qmenubar
opal
mrtg
simple.odata.client
ammonite
typesetting
zbar
jcuda
manifoldcf
atmosphere.js
bootstrap-slider
olingo
kernighan-and-ritchie
insert-update
viewengine
aplpy
storage-duration
clientid
kinto
python-2.3
double-quotes
tabbar
bloodhound
scalariform
omap
emberfire
targetinvocationexception
excel-charts
mui
xsltforms
jxta
colormatrix
re2c
llblgenpro
external-dependencies
broadcom
gora
repeating
nsimageview
wescheme
onmouseout
zmodem
facebook-authentication
jtemplates
having
orthographic
jquery-1.3.2
myisam
ryz
iequalitycomparer
sqlitemanager
palm-pre
mud

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App