I made an extension to UIViewController and inside i have function I use several times:
extension UIViewController {
func transitionToHomeVC() {
let homeViewController = self.storyboard?.instantiateViewController(withIdentifier: NameConstants.StoryBoard.homeViewController) as? HomeViewController
self.view.window?.rootViewController = homeViewController
self.view.window?.makeKeyAndVisible()
}
}
And I have a registration button and as soon as you click if the information was received and correct and etc ... then he has to move me at the to the HomeViewController screen and he does not do it.
He does all the actions but does not pass to screen.
@IBAction func signUpTapped(_ sender: Any) {
// Validate the fields
let error = validDataFields()
if error != nil {
// There's something wrong with the fields, show error message
Service.showError(vc: self, message: error!)
}
else {
// Create cleaned versions of the data
let fireName = firstNameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
let lastName = lastNameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
let email = emailTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
let password = passwordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
// Create the user
Auth.auth().createUser(withEmail: email, password: password) { resulte, err in
// Check for errors
if err != nil {
// There was an error creating the user
Service.showError(vc: self, message: "Error creating user \n make sure you enter: \n current email")
}
else {
// User was created successfully, now store the first name and last name
let db = Firestore.firestore()
db.collection("users").addDocument(data: ["firstName":fireName,"lastName":lastName, "uid": resulte!.user.uid]) { error in
if error != nil {
// Show error message
Service.showError(vc: self, message: " Error saving user Data")
}
}
self.transitionToHomeVC()
}
}
}
}
why it not move to homeViewController?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
how i make a List like at swiftui at storyboard?
the UITableView not the same..
look image:
https://i.ibb.co/Qn69TRR/Untitled.png
how i can do List like a swiftui in storyboard?
I have a problem with the search, it doesn't search for each letter individually,
these only if it is word is together, for example:
I search Kate it will find but if I type Kae (that still has the letters in it), he won't find it, why?
filteredData = contacts.filter {name in
return name.firstName.lowercased().contains(searchText.lowercased()) || name.lastName.lowercased().contains(searchText.lowercased()) || name.telephone.removeCharacters(from: CharacterSet.decimalDigits.inverted).lowercased().contains(searchText.lowercased())
}
i attach screenshot
I’m encountering an issue since I started using Xcode 16. I have a widget in my app, and I'm trying to organize the code by splitting it into different files for better structure.
However, when I do this, I get an error:
error: Unexpected input file: /Users/******/Desktop/TestApp/TestAppWidget/Provider.Swift (in target 'TestAppWidgetExtension' from project 'TestApp')
I want to emphasize that if I keep all the code in one file, everything works fine.
I've checked the Target Membership, and it's set up correctly.
but I don't understand why this is happening only in Xcode 16.
Has anyone else experienced a similar issue or has any ideas on why this is occurring? I would appreciate any help!
How i can open Location services direct to my app?
I want it to go to the screen where the user chooses allow location or not can be enabled in the app..
UIApplication.shared.open(URL(string: "App-prefs:LOCATION_SERVICES")!)
this code open for me only the location services but how i can open location setting to my app?
i created a list with colors and i want when the user click red so all the screen was background red, if user click green so full background is green...
i don't know why but the var not change..
var body: some View {
NavigationView {
List {
Section {
ScreenColorButtons(text: "Red", color: .red)
ScreenColorButtons(text: "Green", color: .green)
ScreenColorButtons(text: "Blue", color: .blue)
}
}
}
}
}
struct ScreenColorButtons: View {
@State static var screenSelected: Color = Color.red
var text: String
var color: Color
var body: some View{
Button(action: {
ScreenColorButtons.screenSelected = color
print(ScreenColorButtons.screenSelected)
}, label: {
NavigationLink(text){}
})
}
}
the ScreenColorView:
struct ScreenColorView: View {
@Environment(\.presentationMode) var presentationMode
var body: some View {
Color.ScreenColorButtons.screenSelected
}
}
why the var not change and error to background??? thank for answer
i have coredata and i want to add bool Optional but i get error:
import CoreData
@objc(HistoryData)
class HistoryData: NSManagedObject {
@NSManaged var firstName: String
@NSManaged var lastName: String
@NSManaged var telephone: String
@NSManaged var time: String
@NSManaged var callHidden: Bool? // Here the error
}
Error:
Property cannot be marked @NSManaged because its type cannot be represented in Objective-C
in xcdatamodeld it selected Optional but it not do it..
why?
I'm facing an issue in my iOS app's architecture involving CoreData, the HistoryCallDataService class, and the HistoryViewModel. I'm hoping someone can help shed light on the problem I'm encountering.
Problem Description:
I'm working with CoreData and have an array that I'm managing through the HistoryCallDataService class.
class HistoryCallDataService {
private let container: NSPersistentContainer
private let containerName = "CallHistoryData"
private let entityName = "HistoryData"
@Published var savedEntities: [HistoryData] = []
I'm observing changes in the savedEntities property of the HistoryCallDataService class using the historyDataService.$savedEntities publisher. When the app starts, the array is updated correctly. However, if I add new content, the savedEntities array updates, but the historyArray in the HistoryViewModel does not reflect these changes.
import Foundation
import Combine
class HistoryViewModel: ObservableObject {
@Published var searchText:String = ""
@Published var historyArray: [HistoryData] = []
private let historyDataService = HistoryCallDataService()
private var cancellables = Set<AnyCancellable>()
var selectedContact: HistoryData? = nil
@Published var filteredContacts: [HistoryData] = []
init(){
addSubscribers()
}
func addSubscribers(){
historyDataService.$savedEntities
.debounce(for: 1.0, scheduler: RunLoop.main)
.sink { [weak self] (returnData) in
guard let self = self else { return }
self.historyArray = returnData
self.updateFilteredContacts()
}
.store(in: &cancellables)
}
func updateFilteredContacts() {
if searchText.isEmpty {
filteredContacts = historyArray
} else {
filteredContacts = historyArray.filter { contact in
contact.firstName?.localizedCaseInsensitiveContains(searchText) ?? false ||
contact.lastName?.localizedCaseInsensitiveContains(searchText) ?? false ||
contact.telephone?.localizedCaseInsensitiveContains(searchText) ?? false
}
}
}
The view:
private var contactList: some View{
List{
ForEach(vm.filteredContacts) { item in
HStack{
VStack(alignment: .leading){
Text("\(item.firstName ?? "N/A") \(item.lastName ?? "N/A" )")
.fontWeight(.semibold)
Text("\(item.telephone ?? "N/A")")
.fontWeight(.medium)
.padding(.top,1)
}
Spacer()
VStack(alignment: .trailing){
Text("\(item.time ?? "N/A")")
.fontWeight(.medium)
Text("\(item.callHidden ? "Hidden" : "Normally ")")
.foregroundColor(item.callHidden ? Color.theme.red : Color.theme.black)
.fontWeight(.bold)
.padding(.top,1)
}
}
.onTapGesture {
vm.selectedContact = item
showingCallAlert.toggle()
}
.listRowBackground(vm.selectedContact?.telephone == item.telephone && showingCallAlert ? Color.theme.gray : nil)
}
.onDelete(perform: { indexSet in
for index in indexSet {
let contactToDelete = vm.filteredContacts[index]
vm.delete(entity: contactToDelete)
}
})
}
.onChange(of:
vm.searchText) { _ in
vm.updateFilteredContacts()
}
.onChange(of: scenePhase) { newPhase in
if newPhase == .active {
print("Active")
vm.updateFilteredContacts()
}
}
.lineLimit(1)
.listStyle(.plain)
}
If anyone has encountered a similar situation or has insights into what might be causing this behavior, I would greatly appreciate your guidance. Thank you in advance for your help!
Hi everyone,
My iOS app performs only a GET request to an external server to receive a JSON with configuration data (e.g., app settings). It does not send any personal data — it's a read-only request used only to adjust app behavior.
Since the app only performs a GET request to the server and does not send any data from the user, no data is collected or stored.
In App Store Connect > App Privacy, is it correct to select: "No, we do not collect data from this app"?
Just want to confirm this is acceptable before submitting. Thanks!
Topic:
App Store Distribution & Marketing
SubTopic:
General
Tags:
App Store Connect
Privacy
App Submission
i have this code:
https://stackoverflow.com/a/50999497/19364094
and when i try to call func showCallAlert() from another ViewController it it not working for me and it not detect if user click call or cancel
what it can do?
I’ve developed an Apple Watch extension for an existing iOS app. When I run the app on the watch via Xcode using the simulator, everything works fine. However, when I try to install it on my iPhone, the Watch app doesn’t show it in the "Available Apps" list, so I can't install it on the watch.
The Apple Watch is connected to my iPhone, and I can see other apps available for installation without any issues.
I also created a brand new project with watchOS support to troubleshoot, but the same problem occurred.
Any ideas on how to resolve this?
Hello,
I am experiencing an issue when trying to open the browser on my Apple Watch SE 2 running the latest version, watchOS 11.6. When I attempt to visit any website, the browser opens and displays the URL at the top as if it is loading, but the screen remains black and no content is displayed.
The internet connection is available, and all other apps on the watch work normally. This issue occurs only with the browser.
I would appreciate any guidance or solution to resolve this problem.
Thank you for your assistance.
class Service: UIViewController {
static func showError(_ message:String) {
// Create new Alert
let dialogMessage = UIAlertController(title: "Error", message: message, preferredStyle: .alert)
// Create OK button with action handler
let ok = UIAlertAction(title: "OK", style: .default, handler: { (action) -> Void in
print("Ok button tapped")
})
//Add OK button to a dialog message
dialogMessage.addAction(ok)
// Present Alert to
self.present(dialogMessage , animated: true, completion: nil)
}
}
why i get error in this line:
self.present(dialogMessage , animated: true, completion: nil)
the error:
Instance member 'present' cannot be used on type 'Service'
why?
I know there is a problem with this.
But I still ask if this is possible to develop call recording in swift?
how i can convert my xcode project to ipa?
i read all the methods but it very old (all methods for xcode 9) and not working..
what i can do?