last day (14 days later) » 

6:45 AM
Hi
 
yup
do u know how to create bridging header in swift?
 
one question for beginning
can I?
 
ya
 
when I create Pods and xcworkspace I must later work just with this xcworkspace, not with xcodeproj, yes?
 
din create a workspace
don't*
also can check this url i have answered it there stackoverflow.com/questions/30318811/…
these method is without the use of thrid party API
 
6:47 AM
okay, I delete it
let's create with the 3rd party, please
okay, now I have my project folder and Pods folder
 
ok
drag drop the the AFNEtworking folder
in to ur project
 
okay, give me a minute
into project or project folder where my files are?
 
project
xcodeproject
 
okay, I did it
 
do u know how to create bridging header in swift?
if NO then u have to learn that first
 
6:53 AM
I did it by creating a new ObjectiveC file and it create the bridge for me
now I have an ObjC file
myProjectName-Bridging-Header.h
is it what I need?
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
inside of
 
#import "AFNetworking.h"
#import "UIImageView+AFNetworking.h"
 
okay, I did it
 
now you will to call thye function
cell.imageView.setImageWithURLRequest
type this you get method name
 
inside of func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
?
 
yes u have to load imageURL rite?
if u r using cusotmCell
then call ur imageView variavble name
 
6:58 AM
yes, var url = NSURL(string: postCover[indexPath.row])

if let data = NSData(contentsOfURL: url!) {
cell.cellImage.image = UIImage(data: data)
}
must I use it inside of this block or?
are you here?
 
yuo
did u suceed
 
no =/
I did try this:
cell.cellImage.setImageWithURLRequest = UIImage(data: data)
 
no
its not like this
 
can you help me with this, please?
 
[imageView setImageWithURLRequest:request placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
blockImageView.image = image;
} failure:nil];
 
7:08 AM
is it not ObjC?
but my code in Swift =/
 
ya type
cell.cellImage.setImageWithURLRequest and press control space
you get the function hint
just replace the parameter
swuft equivalent
cell.imageView.setImageWithURLRequest(request, placeholderImage: nil, success: { [weak cell] request, response, image in
if cell {
cell!.imageView.image = image
}


}, failure:nil)
 
must I fill success and failure?
I set placeholderImage == nil
 
its fine
but its untill your image is downloaded it will show the default image
you can gice default image in placeholde
 
7:26 AM
to this:
cell.imageView.setImageWithURLRequest(url!, placeholderImage: placeholder, success: { [weak cell] request, response, image in
if cell {
cell!.imageView.image = image
}
it prints: Type of expression is more ambiguous without more context
 
where is failure
and set placeeholder as nil
i have given the code use as it is
 
no, I set a placeholder image
 
only change the variable name
 
okay, thanks
 
did it work?
 
7:31 AM
nope
I'm waiting for your code ))
 
i have given the code above
cell.imageView.setImageWithURLRequest(request, placeholderImage: nil, success: { [weak cell] request, response, image in
if cell {
cell!.imageView.image = image
}


}, failure:nil)
in this imageView set ur var name
and change request
according to ur URL
 
it prints the error above I sent
on { [weak cell]
on "{"
Type of expression is more ambiguous without more context
 
remove [weak cell] and try
 
error: Cannot invoke 'setImageWithURLRequest' with an argument list of type '(NSURL, placeholderImage: UIImage?, success: (_, _, _) -> _, failure: nil)'
 
had u made the request var
?
 
7:43 AM
amm, no
is it variable?
 
yup its a url
how will you download a image without a URL
 
oh, yes
i did change it
I think that you are about success: {request, response, image
 
let request = NSURLRequest(URL: book.mediumImageURL)
cell.imageView.setImageWithURLRequest(request, placeholderImage: nil, success: { [weak cell] request, response, image in
if cell {
cell!.imageView.image = image
}


}, failure:nil)
 
I did use the var url = NSURL(string: postCover[indexPath.row])
but with NSURLRequest it gives me the next error
Cannot find an initializer for type 'NSURLRequest' that accepts an argument list of type '(string: (String))'
oops
sorry
just a minute
Cannot find an initializer for type 'NSURLRequest' that accepts an argument list of type '(URL: (String))'
 
let request = NSURLRequest(URL: NSURL(string: postCover[indexPath.row])
 
7:55 AM
oh, it runs!
but
'XCTest/XCTest.h' file not found
#import <XCTest/XCTest.h> in AFTestCase.h
 
i dont think so its necessary
 
what do you advice me to do?
comment it?
 
yup
google it if stll error comes
 
okay, I'm googling
 

last day (14 days later) »