Skip to content

Commit

Permalink
Merge pull request #2 from RaunaqMalhotra/fix-search
Browse files Browse the repository at this point in the history
fix detail view controller when searching
  • Loading branch information
michaeldacanay authored Jun 12, 2023
2 parents 1e02c0b + e81077a commit 34caefa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions BlogSmart/BlogSmart.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
AFA3139729FA22B4003719FE /* PostCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA3139629FA22B4003719FE /* PostCell.swift */; };
AFA3139929FA2A5B003719FE /* Post.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA3139829FA2A5B003719FE /* Post.swift */; };
AFAD94482A007BF900510528 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFAD94472A007BF900510528 /* DetailViewController.swift */; };
AFF89DCF29FDB31300302838 /* Keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = AFF89DCE29FDB31300302838 /* Keys.plist */; };
AFFB8AD72A37CA1E00EBD49B /* Keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = AFFB8AD62A37CA1E00EBD49B /* Keys.plist */; };
BA1BA4F129EA503A00E13CDC /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA1BA4F029EA503A00E13CDC /* LoginViewController.swift */; };
BA1BA4F429EA534100E13CDC /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA1BA4F329EA534100E13CDC /* User.swift */; };
BA1BA4F729EA571700E13CDC /* ViewController+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA1BA4F629EA571700E13CDC /* ViewController+Extensions.swift */; };
Expand All @@ -44,7 +44,7 @@
AFA3139629FA22B4003719FE /* PostCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostCell.swift; sourceTree = "<group>"; };
AFA3139829FA2A5B003719FE /* Post.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = "<group>"; };
AFAD94472A007BF900510528 /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = "<group>"; };
AFF89DCE29FDB31300302838 /* Keys.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Keys.plist; sourceTree = "<group>"; };
AFFB8AD62A37CA1E00EBD49B /* Keys.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Keys.plist; sourceTree = "<group>"; };
BA1BA4F029EA503A00E13CDC /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = "<group>"; };
BA1BA4F329EA534100E13CDC /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
BA1BA4F629EA571700E13CDC /* ViewController+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewController+Extensions.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -104,7 +104,7 @@
AF202F1129E889E800D18F2C /* Assets.xcassets */,
AF202F1329E889E800D18F2C /* LaunchScreen.storyboard */,
AF202F1629E889E800D18F2C /* Info.plist */,
AFF89DCE29FDB31300302838 /* Keys.plist */,
AFFB8AD62A37CA1E00EBD49B /* Keys.plist */,
);
path = BlogSmart;
sourceTree = "<group>";
Expand Down Expand Up @@ -222,7 +222,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AFF89DCF29FDB31300302838 /* Keys.plist in Resources */,
AFFB8AD72A37CA1E00EBD49B /* Keys.plist in Resources */,
AF202F1529E889E800D18F2C /* LaunchScreen.storyboard in Resources */,
AF202F1229E889E800D18F2C /* Assets.xcassets in Resources */,
AF202F1029E889E600D18F2C /* Main.storyboard in Resources */,
Expand Down
Binary file not shown.
12 changes: 8 additions & 4 deletions BlogSmart/BlogSmart/Feed/ReadViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ class ReadViewController: UIViewController {
// Get the index path of the cell from the table view
let indexPath = blogTable.indexPath(for: cell),
// Get the detail view controller
let detailViewController = segue.destination as? DetailViewController {

let detailViewController = segue.destination as? DetailViewController
{

// Use the index path to get the associated post
let post = posts[indexPath.row]

var post = posts[indexPath.row]
if searching {
post = searchedPosts[indexPath.row]
}

// Set the post content on the detail view controller
detailViewController.post = post
}
Expand Down

0 comments on commit 34caefa

Please sign in to comment.